1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-01 12:09:10 +00:00

ChunkIndex.add: remove useless refs parameter

This commit is contained in:
Thomas Waldmann 2024-11-01 23:49:52 +01:00
parent 94effcd782
commit ba3e701730
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
3 changed files with 6 additions and 7 deletions

View file

@ -808,7 +808,7 @@ def add_chunk(
)
self.repository.put(id, cdata, wait=wait)
self.last_refresh_dt = now # .put also refreshed the lock
self.chunks.add(id, 1, size)
self.chunks.add(id, size)
stats.update(size, not exists)
return ChunkListEntry(id, size)

View file

@ -56,8 +56,7 @@ class ChunkIndex(HTProxyMixin, MutableMapping):
def iteritems(self):
yield from self.ht.items()
def add(self, key, refs, size):
assert refs > 0
def add(self, key, size):
v = self.get(key)
if v is None:
flags = self.F_USED

View file

@ -19,14 +19,14 @@ def H2(x):
def test_chunkindex_add():
chunks = ChunkIndex()
x = H2(1)
chunks.add(x, 1, 0)
chunks.add(x, 0)
assert chunks[x] == ChunkIndexEntry(flags=ChunkIndex.F_USED, size=0)
chunks.add(x, 1, 2) # updating size (we do not have a size yet)
chunks.add(x, 2) # updating size (we do not have a size yet)
assert chunks[x] == ChunkIndexEntry(flags=ChunkIndex.F_USED, size=2)
chunks.add(x, 1, 2)
chunks.add(x, 2)
assert chunks[x] == ChunkIndexEntry(flags=ChunkIndex.F_USED, size=2)
with pytest.raises(AssertionError):
chunks.add(x, 1, 3) # inconsistent size (we already have a different size)
chunks.add(x, 3) # inconsistent size (we already have a different size)
def test_keyerror():