From 01fac8d7d9411e0e8d5ee06e2c223f6255e4b823 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Sun, 17 Apr 2016 00:37:40 +0200 Subject: [PATCH] ChunkIndex.add: overwrite current (c)size w/ new values --- borg/hashindex.pyx | 2 ++ borg/testsuite/hashindex.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/borg/hashindex.pyx b/borg/hashindex.pyx index 1f3174427..a99c0f602 100644 --- a/borg/hashindex.pyx +++ b/borg/hashindex.pyx @@ -313,6 +313,8 @@ cdef class ChunkIndex(IndexBase): assert refcount2 <= _MAX_VALUE result64 = refcount1 + refcount2 values[0] = _htole32(min(result64, _MAX_VALUE)) + values[1] = data[1] + values[2] = data[2] else: hashindex_set(self.index, key, data) diff --git a/borg/testsuite/hashindex.py b/borg/testsuite/hashindex.py index fba146952..3aac0c7db 100644 --- a/borg/testsuite/hashindex.py +++ b/borg/testsuite/hashindex.py @@ -174,8 +174,8 @@ def test_chunkindex_add(self): idx1 = ChunkIndex() idx1.add(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): idx1 = ChunkIndex() @@ -266,7 +266,7 @@ def test_read_known_good(self): idx2 = ChunkIndex() idx2[H(3)] = 2**32 - 123456, 6, 7 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():