mirror of https://github.com/borgbackup/borg.git
add_chunk: remove overwrite parameter
This commit is contained in:
parent
15c24cbe7e
commit
0fcd3e9479
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue