From ba3e701730f3e49847af966a20de34e19c8237d0 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 1 Nov 2024 23:49:52 +0100 Subject: [PATCH] ChunkIndex.add: remove useless refs parameter --- src/borg/cache.py | 2 +- src/borg/hashindex.pyx | 3 +-- src/borg/testsuite/hashindex_test.py | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/borg/cache.py b/src/borg/cache.py index 9e50e6975..27f38825f 100644 --- a/src/borg/cache.py +++ b/src/borg/cache.py @@ -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) diff --git a/src/borg/hashindex.pyx b/src/borg/hashindex.pyx index 0d0418e43..00fe68404 100644 --- a/src/borg/hashindex.pyx +++ b/src/borg/hashindex.pyx @@ -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 diff --git a/src/borg/testsuite/hashindex_test.py b/src/borg/testsuite/hashindex_test.py index f0c3d9f8a..2539d351a 100644 --- a/src/borg/testsuite/hashindex_test.py +++ b/src/borg/testsuite/hashindex_test.py @@ -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():