From 231d2d5e08e8b567f9d4e1cf206465170c598b09 Mon Sep 17 00:00:00 2001
From: Kai Reinhard <K.Reinhard@micromata.de>
Date: Tue, 18 Dec 2018 23:27:11 +0000
Subject: [PATCH] Updating cache info about archive file lists works now.
---
borgbutler-core/src/main/java/de/micromata/borgbutler/cache/ButlerCache.java | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/borgbutler-core/src/main/java/de/micromata/borgbutler/cache/ButlerCache.java b/borgbutler-core/src/main/java/de/micromata/borgbutler/cache/ButlerCache.java
index 53b5630..1cfa278 100644
--- a/borgbutler-core/src/main/java/de/micromata/borgbutler/cache/ButlerCache.java
+++ b/borgbutler-core/src/main/java/de/micromata/borgbutler/cache/ButlerCache.java
@@ -5,6 +5,7 @@
import de.micromata.borgbutler.config.Configuration;
import de.micromata.borgbutler.config.ConfigurationHandler;
import de.micromata.borgbutler.data.Archive;
+import de.micromata.borgbutler.data.ArchiveShortInfo;
import de.micromata.borgbutler.data.FileSystemFilter;
import de.micromata.borgbutler.data.Repository;
import de.micromata.borgbutler.json.borg.BorgFilesystemItem;
@@ -20,7 +21,7 @@
import java.util.List;
public class ButlerCache {
- private static Logger log = LoggerFactory.getLogger(ButlerCache.class);
+ private Logger log = LoggerFactory.getLogger(ButlerCache.class);
public static final String CACHE_DIR_NAME = "cache";
private static ButlerCache instance = new ButlerCache();
@@ -123,10 +124,12 @@
return null;
}
if (repository.isArchivesLoaded()) {
+ updateArchivesCacheStatusAndShortInfos(repository);
return repository;
}
BorgRepoConfig repoConfig = ConfigurationHandler.getConfiguration().getRepoConfig(repository.getName());
BorgCommands.list(repoConfig, repository);
+ updateArchivesCacheStatusAndShortInfos(repository);
return repository;
}
@@ -174,9 +177,11 @@
}
if (!forceReload && archive.hasInfoData()) {
// borg info archive was already called.
+ updateArchivesCacheStatusAndShortInfos(repository);
return archive;
}
BorgCommands.info(repoConfig, archive, repository);
+ updateArchivesCacheStatusAndShortInfos(repository);
return archive;
}
@@ -199,6 +204,27 @@
}
/**
+ * Updates for all archives of the given repository the cache status ({@link Archive#isFileListAlreadyCached()} and
+ * updates also the list of {@link ArchiveShortInfo} for all archives of the given repository.
+ *
+ * @param repository
+ */
+ private void updateArchivesCacheStatusAndShortInfos(Repository repository) {
+ if (repository == null || repository.getArchives() == null) {
+ return;
+ }
+ List<ArchiveShortInfo> archiveInfoList = new ArrayList<>();
+ for (Archive archive : repository.getArchives()) {
+ archive.setFileListAlreadyCached(archiveFilelistCache.contains(repository, archive));
+ archiveInfoList.add(new ArchiveShortInfo(archive));
+ }
+ for (Archive archive : repository.getArchives()) {
+ // ArchiveInfoList for comparing current archives with one of all other archives.
+ archive.setArchiveShortInfoList(archiveInfoList);
+ }
+ }
+
+ /**
* @param archiveId
* @param forceLoad If false, the file list will only get if not yet loaded.
* @param filter If not null, the result will be filtered.
--
Gitblit v1.10.0