mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
16.27.2018 289dc3a50c01beb68625b3385308c223f29c3a8b
Search is now 2 times faster.
1 files modified
15 ■■■■ changed files
borgbutler-core/src/main/java/de/micromata/borgbutler/data/FileSystemFilter.java 15 ●●●● patch | view | raw | blame | history
borgbutler-core/src/main/java/de/micromata/borgbutler/data/FileSystemFilter.java
@@ -18,15 +18,22 @@
    private String[] blackListSearchKeyWords;
    public boolean matches(BorgFilesystemItem item) {
        if (searchKeyWords == null && blackListSearchKeyWords == null) {
            return true;
        }
        if (item.getPath() == null) {
            return false;
        }
        String path = item.getPath().toLowerCase();
        if (searchKeyWords != null) {
            for (String searchKeyWord : searchKeyWords) {
                if (!StringUtils.containsIgnoreCase(item.getPath(), searchKeyWord))
                if (!path.contains(searchKeyWord))
                    return false;
            }
        }
        if (blackListSearchKeyWords != null) {
            for (String blackListSearchKeyWord : blackListSearchKeyWords) {
                if (StringUtils.containsIgnoreCase(item.getPath(), blackListSearchKeyWord))
                if (path.contains(blackListSearchKeyWord))
                    return false;
            }
        }
@@ -51,9 +58,9 @@
                    continue;
                }
                if (keyWord.startsWith("!") && keyWord.length() > 1) {
                    blackList.add(keyWord.substring(1));
                    blackList.add(keyWord.substring(1).toLowerCase());
                } else {
                    whiteList.add(keyWord);
                    whiteList.add(keyWord.toLowerCase());
                }
            }
            if (whiteList.size() > 0) {