Bläddra i källkod

ChunkIndex.add: overwrite current (c)size w/ new values

Marian Beermann 9 år sedan
förälder
incheckning
01fac8d7d9
2 ändrade filer med 5 tillägg och 3 borttagningar
  1. 2 0
      borg/hashindex.pyx
  2. 3 3
      borg/testsuite/hashindex.py

+ 2 - 0
borg/hashindex.pyx

@@ -313,6 +313,8 @@ cdef class ChunkIndex(IndexBase):
             assert refcount2 <= _MAX_VALUE
             assert refcount2 <= _MAX_VALUE
             result64 = refcount1 + refcount2
             result64 = refcount1 + refcount2
             values[0] = _htole32(min(result64, _MAX_VALUE))
             values[0] = _htole32(min(result64, _MAX_VALUE))
+            values[1] = data[1]
+            values[2] = data[2]
         else:
         else:
             hashindex_set(self.index, key, data)
             hashindex_set(self.index, key, data)
 
 

+ 3 - 3
borg/testsuite/hashindex.py

@@ -174,8 +174,8 @@ class HashIndexRefcountingTestCase(BaseTestCase):
         idx1 = ChunkIndex()
         idx1 = ChunkIndex()
         idx1.add(H(1), 5, 6, 7)
         idx1.add(H(1), 5, 6, 7)
         assert idx1[H(1)] == (5, 6, 7)
         assert idx1[H(1)] == (5, 6, 7)
-        idx1.add(H(1), 1, 0, 0)
-        assert idx1[H(1)] == (6, 6, 7)
+        idx1.add(H(1), 1, 2, 3)
+        assert idx1[H(1)] == (6, 2, 3)
 
 
     def test_incref_limit(self):
     def test_incref_limit(self):
         idx1 = ChunkIndex()
         idx1 = ChunkIndex()
@@ -266,7 +266,7 @@ class HashIndexDataTestCase(BaseTestCase):
         idx2 = ChunkIndex()
         idx2 = ChunkIndex()
         idx2[H(3)] = 2**32 - 123456, 6, 7
         idx2[H(3)] = 2**32 - 123456, 6, 7
         idx1.merge(idx2)
         idx1.merge(idx2)
-        assert idx1[H(3)] == (hashindex.MAX_VALUE, 0, 0)
+        assert idx1[H(3)] == (hashindex.MAX_VALUE, 6, 7)
 
 
 
 
 def test_nsindex_segment_limit():
 def test_nsindex_segment_limit():