diff --git a/src/borg/cache.py b/src/borg/cache.py index 1f9e77521..4f0032e16 100644 --- a/src/borg/cache.py +++ b/src/borg/cache.py @@ -939,15 +939,13 @@ class LocalCache(CacheStatsMixin): self.cache_config.ignored_features.update(repo_features - my_features) self.cache_config.mandatory_features.update(repo_features & my_features) - def add_chunk( - self, id, meta, data, *, stats, overwrite=False, wait=True, compress=True, size=None, ctype=None, clevel=None - ): + def add_chunk(self, id, meta, data, *, stats, wait=True, compress=True, size=None, ctype=None, clevel=None): if not self.txn_active: self.begin_txn() if size is None and compress: size = len(data) # data is still uncompressed refcount = self.seen_chunk(id, size) - if refcount and not overwrite: + if refcount: return self.chunk_incref(id, stats) if size is None: raise ValueError("when giving compressed data for a new chunk, the uncompressed size must be given also") @@ -1115,8 +1113,7 @@ Chunk index: {0.total_unique_chunks:20d} unknown""" def memorize_file(self, hashed_path, path_hash, st, ids): pass - def add_chunk(self, id, meta, data, *, stats, overwrite=False, wait=True, compress=True, size=None): - assert not overwrite, "AdHocCache does not permit overwrites — trying to use it for recreate?" + def add_chunk(self, id, meta, data, *, stats, wait=True, compress=True, size=None): if not self._txn_active: self.begin_txn() if size is None and compress: diff --git a/src/borg/testsuite/cache.py b/src/borg/testsuite/cache.py index 5f0737f9e..571a483d2 100644 --- a/src/borg/testsuite/cache.py +++ b/src/borg/testsuite/cache.py @@ -192,10 +192,6 @@ class TestAdHocCache: cache.chunk_decref(H(1), Statistics()) assert repository.get(H(1)) == b"1234" - def test_does_not_overwrite(self, cache): - with pytest.raises(AssertionError): - cache.add_chunk(H(1), {}, b"5678", stats=Statistics(), overwrite=True) - def test_seen_chunk_add_chunk_size(self, cache): assert cache.add_chunk(H(1), {}, b"5678", stats=Statistics()) == (H(1), 4)