Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix Blacklist.remove by using pattern.toString to find pattern to remove, parameter String path did never equal Pattern. + delete unused removeAll, as it does not persist changes after restart
reger5e9e8711927e
diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.javaindex 32bf2d9b3..8688d5e1e 100644--- a/source/net/yacy/repository/Blacklist.java+++ b/source/net/yacy/repository/Blacklist.java@@ -33,6 +33,7 @@ import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.PrintWriter;+import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;@@ -256,17 +257,27 @@ public class Blacklist {loadList(blFile, sep);}- public final void removeAll(final BlacklistType blacklistType, final String host) {- getBlacklistMap(blacklistType, true).remove(host);- getBlacklistMap(blacklistType, false).remove(host);- }-+ /**+ * remove the host/path from internal blacklist maps for given blacklistType+ * !! and removes the entry from source blacklist file !!+ * @param blacklistType+ * @param blacklistToUse+ * @param host+ * @param path+ */public final void remove(final BlacklistType blacklistType, final String blacklistToUse, final String host, final String path) {final Map<String, Set<Pattern>> blacklistMap = getBlacklistMap(blacklistType, true);Set<Pattern> hostList = blacklistMap.get(host);if (hostList != null) {- hostList.remove(path);+ // remove pattern from list (by comparing patternstring with path, remove(path) will not match path)+ for (Pattern hp : hostList) {+ String hpxs = hp.pattern();+ if (hpxs.equals(path)) {+ hostList.remove(hp);+ break;+ }+ }if (hostList.isEmpty()) {blacklistMap.remove(host);}@@ -275,12 +286,21 @@ public class Blacklist {final Map<String, Set<Pattern>> blacklistMapNotMatch = getBlacklistMap(blacklistType, false);hostList = blacklistMapNotMatch.get(host);if (hostList != null) {- hostList.remove(path);+ // remove pattern from list+ for (Pattern hp : hostList) {+ String hpxs = hp.pattern();+ if (hpxs.equals(path)) {+ hostList.remove(hp);+ break;+ }+ }if (hostList.isEmpty()) {blacklistMapNotMatch.remove(host);}}+ //TODO: check if delete from blacklist is desired, on reload entry will not be available in any blacklist+ // even if remove (above) from internal maps (at runtime) is only done for given blacklistType// load blacklist data from filefinal List<String> list = FileUtils.getListArray(new File(ListManager.listsPath, blacklistToUse));