add_chunk: remove overwrite parameter

This commit is contained in:
Thomas Waldmann 2023-09-23 00:10:35 +02:00
parent 15c24cbe7e
commit 0fcd3e9479
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
2 changed files with 3 additions and 10 deletions

View File

@ -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:

View File

@ -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)