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

Kai Reinhard
18.27.2018 6a7545312a83454d1007aab27250dc5984f9f42d
Sort order of files: case insensitive and dot files will shown after normal files and directories.
2 files modified
28 ■■■■■ changed files
borgbutler-core/src/main/java/de/micromata/borgbutler/data/FileSystemFilter.java 17 ●●●●● patch | view | raw | blame | history
borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgFilesystemItem.java 11 ●●●●● patch | view | raw | blame | history
borgbutler-core/src/main/java/de/micromata/borgbutler/data/FileSystemFilter.java
@@ -94,6 +94,8 @@
     * After processing a list by using {@link #matches(BorgFilesystemItem)} you should call finally this method with
     * your result list to reduce the files and directories for mode {@link Mode#TREE}. For the mode {@link Mode#FLAT}
     * nothing is done.
     * <br>
     * Reorders the list (.files will be displayed after normal files).
     *
     * @param list
     * @return The original list for mode {@link Mode#FLAT} or the reduced list for the tree view.
@@ -115,6 +117,21 @@
                    list.add(topItem);
                }
            }
            list2 = list;
            // Re-ordering (show dot files at last)
            list = new ArrayList<>();
            // First add normal files:
            for (BorgFilesystemItem item : list2) {
                if (!item.getDisplayPath().startsWith(".")) {
                    list.add(item);
                }
            }
            // Now add dot files:
            for (BorgFilesystemItem item : list2) {
                if (item.getDisplayPath().startsWith(".")) {
                    list.add(item);
                }
            }
        }
        return list;
    }
borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgFilesystemItem.java
@@ -56,6 +56,15 @@
    @Override
    public int compareTo(BorgFilesystemItem o) {
        return StringUtils.compare(this.path, o.path);
        if (path == o.path) {
            return 0;
        }
        if (path == null) {
            return -1;
        }
        if (o.path == null) {
            return  1;
        }
        return path.compareToIgnoreCase(o.path);
    }
}