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

Kai Reinhard
16.34.2018 cf6687899b11ea0d559dd858c1c6ac61e71f8444
lazy loading of file list.
3 files modified
28 ■■■■■ changed files
borgbutler-core/src/main/java/de/micromata/borgbutler/cache/ButlerCache.java 23 ●●●●● patch | view | raw | blame | history
borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/ArchivesRest.java 3 ●●●● patch | view | raw | blame | history
borgbutler-webapp/src/components/views/archives/FileListPanel.jsx 2 ●●● patch | view | raw | blame | history
borgbutler-core/src/main/java/de/micromata/borgbutler/cache/ButlerCache.java
@@ -7,7 +7,6 @@
import de.micromata.borgbutler.data.Archive;
import de.micromata.borgbutler.data.Repository;
import de.micromata.borgbutler.json.borg.BorgFilesystemItem;
import de.micromata.borgbutler.utils.DateUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.jcs.JCS;
import org.apache.commons.jcs.access.CacheAccess;
@@ -181,10 +180,16 @@
    }
    public List<BorgFilesystemItem> getArchiveContent(String archiveId) {
        return getArchiveContent(archiveId, -1);
        return getArchiveContent(archiveId, true, -1);
    }
    public List<BorgFilesystemItem> getArchiveContent(String archiveId, int maxSize) {
    /**
     * @param archiveId
     * @param forceLoad If false, the file list will only get if not yet loaded.
     * @param maxSize
     * @return
     */
    public List<BorgFilesystemItem> getArchiveContent(String archiveId, boolean forceLoad, int maxSize) {
        Archive archive = null;
        outerLoop:
        for (Repository repository : getAllRepositories()) {
@@ -202,32 +207,30 @@
            return null;
        }
        BorgRepoConfig repoConfig = ConfigurationHandler.getConfiguration().getRepoConfig(archive.getRepoId());
        return getArchiveContent(repoConfig, archive, maxSize);
        return getArchiveContent(repoConfig, archive, forceLoad, maxSize);
    }
    /**
     *
     * @param repoConfig
     * @param archive
     * @return
     */
    public List<BorgFilesystemItem> getArchiveContent(BorgRepoConfig repoConfig, Archive archive) {
        return getArchiveContent(repoConfig, archive, -1);
        return getArchiveContent(repoConfig, archive, true, -1);
    }
    /**
     *
     * @param repoConfig
     * @param archive
     * @param maxSize Max result size (default is -1 meaning all).
     * @return
     */
    public List<BorgFilesystemItem> getArchiveContent(BorgRepoConfig repoConfig, Archive archive, int maxSize) {
    public List<BorgFilesystemItem> getArchiveContent(BorgRepoConfig repoConfig, Archive archive, boolean forceLoad, int maxSize) {
        if (archive == null || StringUtils.isBlank(archive.getName())) {
            return null;
        }
        List<BorgFilesystemItem> items = archiveFilelistCache.load(repoConfig, archive, maxSize);
        if (items == null) {
        if (items == null && forceLoad) {
            List<BorgFilesystemItem> list = BorgCommands.listArchiveContent(repoConfig, archive.getName());
            if (CollectionUtils.isNotEmpty(list)) {
                archiveFilelistCache.save(repoConfig, archive, list);
@@ -239,7 +242,7 @@
                }
            }
        }
        if (items == null) {
        if (items == null && forceLoad) {
            log.warn("Repo::archiv with name '" + archive.getBorgIdentifier() + "' not found.");
        }
        return items;
borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/ArchivesRest.java
@@ -42,6 +42,7 @@
    /**
     *
     * @param archiveId Id or name of archive.
     * @param forceLoad If false (default), non cached file lists will not be loaded by borg.
     * @param maxResultSize maximum number of file items to return (default is 50).
     * @param prettyPrinter If true then the json output will be in pretty format.
     * @return Repository (including list of archives) as json string.
@@ -52,7 +53,7 @@
                                     @QueryParam("force") boolean force,
                                     @QueryParam("prettyPrinter") boolean prettyPrinter) {
        int maxSize = maxResultSize != null ? maxResultSize : 50;
        List<BorgFilesystemItem> items = ButlerCache.getInstance().getArchiveContent(archiveId, maxSize);
        List<BorgFilesystemItem> items = ButlerCache.getInstance().getArchiveContent(archiveId, force, maxSize);
        if (items == null) {
            return "";
        }
borgbutler-webapp/src/components/views/archives/FileListPanel.jsx
@@ -11,7 +11,7 @@
    };
    componentDidMount = () => {
        this.fetchArchiveFileList();
        this.fetchArchiveFileList(false);
    };