diff --git a/src/borg/cache.py b/src/borg/cache.py index a7f6bc53c..99709d172 100644 --- a/src/borg/cache.py +++ b/src/borg/cache.py @@ -428,6 +428,9 @@ def __str__(self): def stats(self): from .archive import Archive + if isinstance(self, AdHocCache) and getattr(self, "chunks", None) is None: + self.chunks = self._load_chunks_from_repo() # AdHocCache usually only has .chunks after begin_txn. + # XXX: this should really be moved down to `hashindex.pyx` total_size, unique_size, total_unique_chunks, total_chunks = self.chunks.summarize() # since borg 1.2 we have new archive metadata telling the total size per archive, @@ -1340,8 +1343,6 @@ def __init__(self, manifest, warn_if_unencrypted=True, lock_wait=None, iec=False self.security_manager = SecurityManager(self.repository) self.security_manager.assert_secure(manifest, self.key, lock_wait=lock_wait) - logger.warning("Note: --no-cache-sync is an experimental feature.") - # Public API def __enter__(self): diff --git a/src/borg/testsuite/archiver/corruption.py b/src/borg/testsuite/archiver/corruption.py index 965d2d1d2..65804eaca 100644 --- a/src/borg/testsuite/archiver/corruption.py +++ b/src/borg/testsuite/archiver/corruption.py @@ -53,11 +53,10 @@ def test_cache_chunks(archiver): create_src_archive(archiver, "test") chunks_path = os.path.join(archiver.cache_path, "chunks") - chunks_before_corruption = set(ChunkIndex(path=chunks_path).iteritems()) + if not os.path.exists(chunks_path): + pytest.skip("no persistent chunks index for this kind of Cache implementation") - chunks_index = os.path.join(archiver.cache_path, "chunks") - if not os.path.exists(chunks_index): - pytest.skip("Only works with LocalCache.") + chunks_before_corruption = set(ChunkIndex(path=chunks_path).iteritems()) corrupt(chunks_path) diff --git a/src/borg/testsuite/archiver/create_cmd.py b/src/borg/testsuite/archiver/create_cmd.py index 82b7c7af7..a19490041 100644 --- a/src/borg/testsuite/archiver/create_cmd.py +++ b/src/borg/testsuite/archiver/create_cmd.py @@ -546,8 +546,8 @@ def test_create_no_cache_sync_adhoc(archivers, request): # TODO: add test for N cmd(archiver, "rcreate", RK_ENCRYPTION) cmd(archiver, "rdelete", "--cache-only") create_json = json.loads( - cmd(archiver, "create", "--no-cache-sync", "--prefer-adhoc-cache", "--json", "--error", "test", "input") - ) # ignore experimental warning + cmd(archiver, "create", "--no-cache-sync", "--prefer-adhoc-cache", "--json", "test", "input") + ) info_json = json.loads(cmd(archiver, "info", "-a", "test", "--json")) create_stats = create_json["cache"]["stats"] info_stats = info_json["cache"]["stats"]