From 1843ea7e69865d80aba7fb024b4dc54c2c2fc2a9 Mon Sep 17 00:00:00 2001 From: reger Date: Tue, 2 Aug 2016 02:41:03 +0200 Subject: [PATCH] on Blacklist.add pattern to source file also update internal entry maps as in Blacklist.add(blacklistType) to make entry effective w/o restart fix for http://mantis.tokeek.de/view.php?id=676 --- source/net/yacy/repository/Blacklist.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.java index 0289ab86a..32bf2d9b3 100644 --- a/source/net/yacy/repository/Blacklist.java +++ b/source/net/yacy/repository/Blacklist.java @@ -297,9 +297,9 @@ public class Blacklist { } /** - * + * Adds entry to a given blacklist internal data and updates the source file * @param blacklistType - * @param blacklistToUse + * @param blacklistToUse source file * @param host * @param path * @throws PunycodeException @@ -362,7 +362,7 @@ public class Blacklist { } /** - * appends aN entry to the backlist source file. + * appends aN entry to the backlist source file and updates internal blacklist maps. * * @param blacklistSourcefile name of the blacklist file (LISTS/*.black) * @param host host or host pattern @@ -387,8 +387,21 @@ public class Blacklist { if (!p.isEmpty() && p.charAt(0) == '*') { p = "." + p; - } + } Pattern pattern = Pattern.compile(p, Pattern.CASE_INSENSITIVE); + + // update (put) pattern to internal blacklist maps (for which source is active) + for (final BlacklistType supportedBlacklistType : BlacklistType.values()) { + if (ListManager.listSetContains(supportedBlacklistType + ".BlackLists", blacklistSourcefile)) { + final Map> blacklistMap = getBlacklistMap(supportedBlacklistType, isMatchable(host)); + Set hostList; + if (!(blacklistMap.containsKey(h) && ((hostList = blacklistMap.get(h)) != null))) { + blacklistMap.put(h, (hostList = new HashSet())); + } + hostList.add(pattern); + } + } + // Append the line to the file. PrintWriter pw = null; try {