bugfixes/empty-dir-deletion/snippet-test-activation

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@212 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 20 years ago
parent 2d85bdb341
commit ee0758fe4d

@ -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>

@ -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 &le; " + messagesize + " kb and an attachment &le; " + 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 &le; " + messagesize + " kb and an attachment &le; " + 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 properties

@ -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>

@ -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());
}
}
}
}
}
}

@ -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;
}

@ -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();

Loading…
Cancel
Save