diff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.java index 82ac95754..5360216b4 100644 --- a/htroot/BlacklistCleaner_p.java +++ b/htroot/BlacklistCleaner_p.java @@ -53,6 +53,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -119,10 +120,10 @@ public class BlacklistCleaner_p { if (post.containsKey("delete")) { prop.put(RESULTS + "modified", 1); - prop.put(RESULTS + "modified_delCount", removeEntries(blacklistToUse, supportedBlacklistTypes, getByPrefix(post, "select", true))); + prop.put(RESULTS + "modified_delCount", removeEntries(blacklistToUse, supportedBlacklistTypes, getByPrefix(post, "select", true, true))); } else if (post.containsKey("alter")) { prop.put(RESULTS + "modified", 2); - prop.put(RESULTS + "modified_alterCount", alterEntries(blacklistToUse, supportedBlacklistTypes, getByPrefix(post, "select", true), getByPrefix(post, "entry", false))); + prop.put(RESULTS + "modified_alterCount", alterEntries(blacklistToUse, supportedBlacklistTypes, getByPrefix(post, "select", true, false), getByPrefix(post, "entry", false, false))); } // list illegal entries @@ -171,8 +172,13 @@ public class BlacklistCleaner_p { } } - private static String[] getByPrefix(serverObjects post, String prefix, boolean useKeys) { - ArrayList r = new ArrayList(); + private static String[] getByPrefix(serverObjects post, String prefix, boolean useKeys, boolean useHashSet) { + Collection r; + if (useHashSet) { + r = new HashSet(); + } else { + r = new ArrayList(); + } Iterator it; String s; if (useKeys) { @@ -280,9 +286,12 @@ public class BlacklistCleaner_p { // remove the entry from the running blacklist engine for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) { if (listManager.ListInListslist(supportedBlacklistTypes[blTypes] + ".BlackLists", blacklistToUse)) { + String host = (s.indexOf("/") == -1) ? s : s.substring(0, s.indexOf("/")); + String path = (s.indexOf("/") == -1) ? ".*" : s.substring(s.indexOf("/") + 1); + try { plasmaSwitchboard.urlBlacklist.remove(supportedBlacklistTypes[blTypes], - (s.indexOf("/") == -1) ? s : s.substring(0, s.indexOf("/")), - (s.indexOf("/") == -1) ? ".*" : s.substring(s.indexOf("/") + 1)); + host,path); + } catch (RuntimeException e) { System.err.println(e.getMessage() + ": " + host + "/" + path); } } } } diff --git a/htroot/CacheAdmin_p.java b/htroot/CacheAdmin_p.java index c9c28e136..da1b691ac 100644 --- a/htroot/CacheAdmin_p.java +++ b/htroot/CacheAdmin_p.java @@ -51,6 +51,7 @@ */ import java.io.File; +import java.io.FilenameFilter; import java.io.Writer; import java.util.Iterator; import java.util.Map; @@ -61,6 +62,7 @@ import de.anomic.htmlFilter.htmlFilterImageEntry; import de.anomic.htmlFilter.htmlFilterWriter; import de.anomic.http.httpHeader; import de.anomic.net.URL; +import de.anomic.plasma.plasmaHTCache; import de.anomic.plasma.plasmaParserDocument; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.cache.IResourceInfo; @@ -78,6 +80,15 @@ public class CacheAdmin_p { private static final int HtmlFile = 0; private static final int NotCached = 1; private static final int Image = 2; + + public static final class Filter implements FilenameFilter { + private static final String EXCLUDE_NAME = plasmaHTCache.DB_NAME; + private final File EXCLUDE_DIR; + public Filter(File path) { this.EXCLUDE_DIR = path; } + public boolean accept(File dir, String name) { + return !dir.equals(EXCLUDE_DIR) && !name.equals(EXCLUDE_NAME); + } + } public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { final plasmaSwitchboard switchboard = (plasmaSwitchboard) env; @@ -107,7 +118,7 @@ public class CacheAdmin_p { String urlstr = ""; - if (action.equals("info") && !file.isDirectory()) { // normal file + if (action.equals("info") && !file.isDirectory() && url != null) { // normal file prop.put("info", TypeFILE); // path.append((pathString.length() == 0) ? linkPathString("/", true) : linkPathString(pathString, false)); linkPathString(prop, ((pathString.length() == 0) ? ("/") : (pathString)), true); @@ -187,7 +198,7 @@ public class CacheAdmin_p { } // generate sorted dir/file listing - final String[] list = dir.list(); + final String[] list = dir.list(new Filter(new File(switchboard.getConfig(plasmaSwitchboard.HTCACHE_PATH, plasmaSwitchboard.HTCACHE_PATH_DEFAULT)))); tree.ensureCapacity((list == null) ? 70 : (list.length + 1) * 256); linkPathString(prop, ((pathString.length() == 0) ? ("/") : (pathString)), true); if (list == null) { @@ -196,16 +207,12 @@ public class CacheAdmin_p { prop.put("info_empty", 0); final TreeSet dList = new TreeSet(); final TreeSet fList = new TreeSet(); - File object; int size = list.length - 1, i = size; for (; i >= 0 ; i--) { // Rueckwaerts ist schneller - object = new File(dir, list[i]); - if (!object.getName().equalsIgnoreCase("responseHeader.db")) { - if (object.isDirectory()) - dList.add(list[i]); - else - fList.add(list[i]); - } + if (new File(dir, list[i]).isDirectory()) + dList.add(list[i]); + else + fList.add(list[i]); } Iterator iter = dList.iterator(); diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java index 964099085..9f56ddfd8 100644 --- a/source/de/anomic/plasma/plasmaHTCache.java +++ b/source/de/anomic/plasma/plasmaHTCache.java @@ -93,7 +93,9 @@ import de.anomic.yacy.yacySeed; import de.anomic.yacy.yacySeedDB; public final class plasmaHTCache { - + + public static final String DB_NAME = "responseHeader1.db"; + private static final int stackLimit = 150; // if we exceed that limit, we do not check idle public static final long oneday = 1000 * 60 * 60 * 24; // milliseconds of a day @@ -189,14 +191,14 @@ public final class plasmaHTCache { private void resetResponseHeaderDB() { if (this.responseHeaderDB != null) this.responseHeaderDB.close(); - File dbfile = new File(this.cachePath, "responseHeader1.db"); + File dbfile = new File(this.cachePath, DB_NAME); if (dbfile.exists()) dbfile.delete(); openResponseHeaderDB(0); } private void openResponseHeaderDB(long preloadTime) { // open the response header database - File dbfile = new File(this.cachePath, "responseHeader1.db"); + File dbfile = new File(this.cachePath, DB_NAME); this.responseHeaderDB = new kelondroMapObjects(new kelondroDyn(dbfile, true, true, preloadTime, yacySeedDB.commonHashLength, 150, '#', kelondroBase64Order.enhancedCoder, true, false, true), 500); }