mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-23 22:51:35 +00:00
Merge pull request #925 from enkore/fix/hashindexadd
Cache: update add_chunk to use ChunkIndex.add
This commit is contained in:
commit
77966c7007
3 changed files with 7 additions and 5 deletions
|
@ -378,8 +378,8 @@ def add_chunk(self, id, data, stats, overwrite=False):
|
|||
data = self.key.encrypt(data)
|
||||
csize = len(data)
|
||||
self.repository.put(id, data, wait=False)
|
||||
self.chunks[id] = ChunkIndexEntry(refcount + 1, size, csize)
|
||||
stats.update(size, csize, True)
|
||||
self.chunks.add(id, 1, size, csize)
|
||||
stats.update(size, csize, not refcount)
|
||||
return ChunkListEntry(id, size, csize)
|
||||
|
||||
def seen_chunk(self, id, size=None):
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue