Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
bugfixes/empty-dir-deletion/snippet-test-activation
orbiteree0758fe4d73
diff --git a/build.xml b/build.xmlindex 39c0796d8..05cfc9c52 100644--- a/build.xml+++ b/build.xml@@ -248,14 +248,14 @@<include name="startYACY.sh"/><include name="stopYACY.sh"/><include name="killYACY.sh"/>+ <include name="startYACY.command"/>+ <include name="stopYACY.command"/></tarfileset><!-- copy other wrappers --><tarfileset dir="." dirmode="${accessRightsDir}" mode="${accessRightsFile}" prefix="${releaseDir}">- <include name="startYACY.command"/><include name="startYACY.bat"/><include name="startYACY_noconsole.bat"/>- <include name="stopYACY.command"/><include name="stopYACY.bat"/></tarfileset>diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.javaindex 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 += "<p>The peer '" + peerName + "' is alive and responded:<br>";- body += "'" + response + " You are allowed to send me a message ≤ " + messagesize + " kb and an attachment ≤ " + attachmentsize + ".'</p>";- body += "<form action=\"MessageSend_p.html\" method=\"post\" enctype=\"multipart/form-data\" accept-charset=\"UTF-8\"><br><br>";- body += "<p><h3>Your Message</h3></p>";- body += "<p>Subject:<br><input name=\"subject\" type=\"text\" size=\"80\" maxlength=\"80\" value=\"" + subject + "\"></p>";- body += "<p>Text:<br><textarea name=\"message\" cols=\"80\" rows=\"8\"></textarea></p>";- body += "<input type=\"hidden\" name=\"hash\" value=\"" + hash + "\">";- body += "<input type=\"hidden\" name=\"messagesize\" value=\"" + messagesize + "\">";- body += "<input type=\"hidden\" name=\"attachmentsize\" value=\"" + attachmentsize + "\">";- body += "<input name=\"new\" type=\"submit\" value=\"Enter\"></form>";+ // write input form+ try {+ int messagesize = Integer.parseInt((String) result.get("messagesize"));+ int attachmentsize = Integer.parseInt((String) result.get("attachmentsize"));+ body += "<p>The peer '" + peerName + "' is alive and responded:<br>";+ body += "'" + response + " You are allowed to send me a message ≤ " + messagesize + " kb and an attachment ≤ " + attachmentsize + ".'</p>";+ body += "<form action=\"MessageSend_p.html\" method=\"post\" enctype=\"multipart/form-data\" accept-charset=\"UTF-8\"><br><br>";+ body += "<p><h3>Your Message</h3></p>";+ body += "<p>Subject:<br><input name=\"subject\" type=\"text\" size=\"80\" maxlength=\"80\" value=\"" + subject + "\"></p>";+ body += "<p>Text:<br><textarea name=\"message\" cols=\"80\" rows=\"8\"></textarea></p>";+ body += "<input type=\"hidden\" name=\"hash\" value=\"" + hash + "\">";+ body += "<input type=\"hidden\" name=\"messagesize\" value=\"" + messagesize + "\">";+ body += "<input type=\"hidden\" name=\"attachmentsize\" value=\"" + attachmentsize + "\">";+ body += "<input name=\"new\" type=\"submit\" value=\"Enter\"></form>";+ } catch (NumberFormatException e) {+ // "unresolved pattern", the remote peer is alive but had an exception+ body += "<p>The peer '" + peerName + "' is alive but cannot respond. Sorry..</p>";+ }}} 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 += "<p>Your message has been send. The target peer respondet:</p>";- body += "<p><i>" + result.get("response") + "</i></p>";+ // 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 += "<p>Your message has been send. The target peer respondet:</p>";+ body += "<p><i>" + result.get("response") + "</i></p>";+ } catch (NumberFormatException e) {+ // "unresolved pattern", the remote peer is alive but had an exception+ body += "<p>The target peer is alive but did not receive your message. Sorry..</p>";+ body += "<p>Here is a copy of your message, so you can copy it to save it for further attempts:<br>";+ body += message;+ body += "</p>";+ }}// return rewrite propertiesdiff --git a/htroot/index.html b/htroot/index.htmlindex cef596033..ccdf03277 100644--- a/htroot/index.html+++ b/htroot/index.html@@ -106,11 +106,9 @@ from 'late' peers to enricht this search result.</b><br>#(snippet)#::-<!--<i>#[text]#</i><br>--->#(/snippet)#<a href="#[url]#">#[urlname]#</a><br>#[date]#<br></p>diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.javaindex 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 managementcacheAge = 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 elementsserverInstantThread.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.javaindex 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-bufferprivate 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 folderTreeSet 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.javaindex 84d95a6f4..77a5fef61 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -404,7 +404,7 @@ public final class yacy {// find all hashesserverLog.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();