ソースを参照

ChunkIndex.add: remove useless refs parameter

Thomas Waldmann 7 ヶ月 前
コミット
ba3e701730
3 ファイル変更6 行追加7 行削除
  1. 1 1
      src/borg/cache.py
  2. 1 2
      src/borg/hashindex.pyx
  3. 4 4
      src/borg/testsuite/hashindex_test.py

+ 1 - 1
src/borg/cache.py

@@ -808,7 +808,7 @@ class ChunksMixin:
         )
         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)
 

+ 1 - 2
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

+ 4 - 4
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():