*) More verbose output on ftp-seed-upload failure

See: http://www.yacy-forum.de/viewtopic.php?p=8000#8000

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@605 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent e3aa3a2d75
commit 3dfda1c9da

@ -1863,34 +1863,45 @@ cd ..
} }
public static String put(String host, public static String put(String host,
File localFile, String remotePath, String remoteName, File localFile, String remotePath, String remoteName,
String account, String password) { String account, String password) throws IOException {
// returns the log // returns the log
try { try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos); PrintStream out = new PrintStream(bout);
ftpc c = new ftpc(System.in, out, out);
c.exec("open " + host, false); ByteArrayOutputStream berr = new ByteArrayOutputStream();
c.exec("user " + account + " " + password, false); PrintStream err = new PrintStream(berr);
if (remotePath != null) {
remotePath = remotePath.replace('\\', '/'); ftpc c = new ftpc(System.in, out, err);
c.exec("open " + host, false);
c.exec("user " + account + " " + password, false);
if (remotePath != null) {
remotePath = remotePath.replace('\\', '/');
c.exec("cd " + remotePath, false); c.exec("cd " + remotePath, false);
} }
c.exec("binary", false); c.exec("binary", false);
c.exec("put " + localFile.toString() + ((remoteName.length() == 0) ? "" : (" " + remoteName)), false); c.exec("put " + localFile.toString() + ((remoteName.length() == 0) ? "" : (" " + remoteName)), false);
c.exec("close", false); c.exec("close", false);
c.exec("exit", false); c.exec("exit", false);
out.close();
String log = baos.toString(); out.close();
baos.close(); err.close();
return log;
} catch (IOException e) { String outLog = bout.toString();
return ""; bout.close();
} catch (java.security.AccessControlException e) {
System.out.println("ERROR: ftp put failed:" + e.getMessage()); String errLog = berr.toString();
e.printStackTrace(); berr.close();
return "";
} if (errLog.length() > 0) {
throw new IOException ("Ftp put failed:\n" + errLog);
}
return outLog;
} catch (IOException e) {
throw e;
}
} }
public static void get(String host, public static void get(String host,
@ -1925,9 +1936,13 @@ cd ..
public pt(String h, File l, String rp, String rn, String a, String p) { public pt(String h, File l, String rp, String rn, String a, String p) {
host = h; localFile = l; remotePath = rp; remoteName = rn; account = a; password = p; host = h; localFile = l; remotePath = rp; remoteName = rn; account = a; password = p;
} }
public final void run() { public final void run() {
put(host, localFile, remotePath, remoteName, account, password); try {
} put(host, localFile, remotePath, remoteName, account, password);
} catch (IOException e) {
e.printStackTrace();
}
}
} }
public static Thread putAsync(String host, public static Thread putAsync(String host,
@ -1989,7 +2004,12 @@ cd ..
if (args[0].equals("-get")) { if (args[0].equals("-get")) {
get(args[1], args[2], new File(args[3]), args[4], args[5]); get(args[1], args[2], new File(args[3]), args[4], args[5]);
} else if (args[0].equals("-put")) { } else if (args[0].equals("-put")) {
put(args[1], new File(args[2]), args[3], "", args[4], args[5]); try {
put(args[1], new File(args[2]), args[3], "", args[4], args[5]);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else { } else {
printHelp(); printHelp();
} }

@ -586,9 +586,13 @@ public class yacySeedDB {
} }
if ((check == null) || (uv == null) || (uv.size() != check.size())) { if ((check == null) || (uv == null) || (uv.size() != check.size())) {
serverLog.logDebug("YACY","SaveSeedList: Local and uploades seed-list " +
"contains varying numbers of entries." +
"\n\tLocal seed-list: " + uv.size() + " entries" +
"\n\tRemote seed-list: " + check.size() + " enties");
return false; return false;
} else { } else {
serverLog.logDebug("YACY","SaveSeedList: Comparing local and uploades seed-list ..."); serverLog.logDebug("YACY","SaveSeedList: Comparing local and uploades seed-list entries ...");
int i; int i;
for (i = 0; i < uv.size(); i++) { for (i = 0; i < uv.size(); i++) {
if (!(((String) uv.elementAt(i)).equals((String) check.elementAt(i)))) return false; if (!(((String) uv.elementAt(i)).equals((String) check.elementAt(i)))) return false;

Loading…
Cancel
Save