diff --git a/build.xml b/build.xml index 39c0796d8..05cfc9c52 100644 --- a/build.xml +++ b/build.xml @@ -248,14 +248,14 @@ + + - - diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.java index f2b2a0640..62e48b1fa 100644 --- a/htroot/MessageSend_p.java +++ b/htroot/MessageSend_p.java @@ -102,31 +102,44 @@ public class MessageSend_p { yacyCore.peerActions.disconnectPeer(targetPeer); } } else { - // write input form - int messagesize = Integer.parseInt((String) result.get("messagesize")); - int attachmentsize = Integer.parseInt((String) result.get("attachmentsize")); - body += "

The peer '" + peerName + "' is alive and responded:
"; - body += "'" + response + " You are allowed to send me a message ≤ " + messagesize + " kb and an attachment ≤ " + attachmentsize + ".'

"; - body += "


"; - body += "

Your Message

"; - body += "

Subject:

"; - body += "

Text:

"; - body += ""; - body += ""; - body += ""; - body += "
"; + // write input form + try { + int messagesize = Integer.parseInt((String) result.get("messagesize")); + int attachmentsize = Integer.parseInt((String) result.get("attachmentsize")); + body += "

The peer '" + peerName + "' is alive and responded:
"; + body += "'" + response + " You are allowed to send me a message ≤ " + messagesize + " kb and an attachment ≤ " + attachmentsize + ".'

"; + body += "


"; + body += "

Your Message

"; + body += "

Subject:

"; + body += "

Text:

"; + body += ""; + body += ""; + body += ""; + body += "
"; + } catch (NumberFormatException e) { + // "unresolved pattern", the remote peer is alive but had an exception + body += "

The peer '" + peerName + "' is alive but cannot respond. Sorry..

"; + } } } else { - // send written message to peer - int messagesize = Integer.parseInt(post.get("messagesize", "0")); - int attachmentsize = Integer.parseInt(post.get("attachmentsize", "0")); - - if (messagesize < 1000) messagesize = 1000; // debug - if (subject.length() > 100) subject = subject.substring(0, 100); - if (message.length() > messagesize) message = message.substring(0, messagesize); - HashMap result = yacyClient.postMessage(hash, subject, message.getBytes()); - body += "

Your message has been send. The target peer respondet:

"; - body += "

" + result.get("response") + "

"; + // send written message to peer + try { + int messagesize = Integer.parseInt(post.get("messagesize", "0")); + int attachmentsize = Integer.parseInt(post.get("attachmentsize", "0")); + + if (messagesize < 1000) messagesize = 1000; // debug + if (subject.length() > 100) subject = subject.substring(0, 100); + if (message.length() > messagesize) message = message.substring(0, messagesize); + HashMap result = yacyClient.postMessage(hash, subject, message.getBytes()); + body += "

Your message has been send. The target peer respondet:

"; + body += "

" + result.get("response") + "

"; + } catch (NumberFormatException e) { + // "unresolved pattern", the remote peer is alive but had an exception + body += "

The target peer is alive but did not receive your message. Sorry..

"; + body += "

Here is a copy of your message, so you can copy it to save it for further attempts:
"; + body += message; + body += "

"; + } } // return rewrite properties diff --git a/htroot/index.html b/htroot/index.html index cef596033..ccdf03277 100644 --- a/htroot/index.html +++ b/htroot/index.html @@ -106,11 +106,9 @@ from 'late' peers to enricht this search result.
#(snippet)# :: - #(/snippet)# #[urlname]#
#[date]#

diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java index 70ca288c3..2924cb25c 100644 --- a/source/de/anomic/plasma/plasmaHTCache.java +++ b/source/de/anomic/plasma/plasmaHTCache.java @@ -133,9 +133,8 @@ public final class plasmaHTCache { // init cache age and size management cacheAge = new TreeMap(); currCacheSize = 0; - maxCacheSize = Long.parseLong(switchboard.getConfig("proxyCacheSize", "2")); // this is megabyte - maxCacheSize = maxCacheSize * 1024 * 1024; // now it's the number of bytes - + maxCacheSize = 1024 * 1024 * Long.parseLong(switchboard.getConfig("proxyCacheSize", "2")); // this is megabyte + // start the cache startup thread // this will collect information about the current cache size and elements serverInstantThread.oneTimeJob(this, "cacheScan", log, 5000); @@ -157,7 +156,7 @@ public final class plasmaHTCache { //log.logSystem("STARTING CACHE SCANNING"); kelondroMScoreCluster doms = new kelondroMScoreCluster(); int c = 0; - enumerateFiles ef = new enumerateFiles(cachePath, true, false, true); + enumerateFiles ef = new enumerateFiles(cachePath, true, false, true, true); File f; while (ef.hasMoreElements()) { c++; @@ -338,8 +337,17 @@ public final class plasmaHTCache { f = (File) cacheAge.remove(cacheAge.firstKey()); if (f.exists()) { currCacheSize -= f.length(); - f.delete(); - log.logInfo("DELETED OLD CACHE : " + f.toString()); + if (f.delete()) { + log.logInfo("DELETED OLD CACHE : " + f.toString()); + f = f.getParentFile(); + if ((f.exists()) && (f.isDirectory())) { + // check size of directory + if (f.list().length == 0) { + // the directory has no files in it; delete it also + if (f.delete()) log.logInfo("DELETED EMPTY DIRECTORY : " + f.toString()); + } + } + } } } } diff --git a/source/de/anomic/tools/enumerateFiles.java b/source/de/anomic/tools/enumerateFiles.java index 4adf5b007..932369e6a 100644 --- a/source/de/anomic/tools/enumerateFiles.java +++ b/source/de/anomic/tools/enumerateFiles.java @@ -55,21 +55,23 @@ public class enumerateFiles implements Enumeration { private Object buffer; // the prefetch-buffer private boolean return_files; private boolean return_folders; + private boolean delete_emptyFolders; - public enumerateFiles(File root, boolean files, boolean folders, boolean increasing) { + public enumerateFiles(File root, boolean files, boolean folders, boolean increasing, boolean deleteEmptyFolders) { // we define our data structures first - return_files = files; - return_folders = folders; - hierarchy = new ArrayList(); - incOrder = increasing; + this.return_files = files; + this.return_folders = folders; + this.delete_emptyFolders = deleteEmptyFolders; + this.hierarchy = new ArrayList(); + this.incOrder = increasing; // the we initially fill the hierarchy with the content of the root folder TreeSet t = new TreeSet(); String[] l = root.list(); // System.out.println("D " + l.toString()); for (int i = 0; i < l.length; i++) t.add(new File(root, l[i])); - hierarchy.add(t); + this.hierarchy.add(t); // start with search by filling the buffer - buffer = nextElement0(); + this.buffer = nextElement0(); } private Object nextElement0() { @@ -94,9 +96,18 @@ public class enumerateFiles implements Enumeration { if (f.isDirectory()) { t = new TreeSet(); String[] l = f.list(); - for (int i = 0; i < l.length; i++) t.add(new File(f, l[i])); - hierarchy.add(t); - if (!(return_folders)) f = null; + if (l.length == 0) { + if (delete_emptyFolders) { + f.delete(); + f = null; + } else { + if (!(return_folders)) f = null; + } + } else { + for (int i = 0; i < l.length; i++) t.add(new File(f, l[i])); + hierarchy.add(t); + if (!(return_folders)) f = null; + } } else { if (!(return_files)) f = null; } diff --git a/source/yacy.java b/source/yacy.java index 84d95a6f4..77a5fef61 100644 --- a/source/yacy.java +++ b/source/yacy.java @@ -404,7 +404,7 @@ public final class yacy { // find all hashes serverLog.logInfo("GEN-WORDSTAT", "searching all word-hash databases..."); File dbRoot = new File(homePath, config.getProperty("dbPath")); - enumerateFiles ef = new enumerateFiles(new File(dbRoot, "WORDS"), true, false, true); + enumerateFiles ef = new enumerateFiles(new File(dbRoot, "WORDS"), true, false, true, true); File f; String h; kelondroMScoreCluster hs = new kelondroMScoreCluster();