1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-04 10:39:50 +00:00

Merge pull request #7057 from ThomasWaldmann/fix-recreate-fixed-chunker-1.2

get_chunker: fix missing sparse=False argument, fixes #7056
This commit is contained in:
TW 2022-09-27 22:36:03 +02:00 committed by GitHub
commit 773f3bff77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -349,7 +349,7 @@ class ChunkBuffer:
self.packer = msgpack.Packer()
self.chunks = []
self.key = key
self.chunker = get_chunker(*chunker_params, seed=self.key.chunk_seed)
self.chunker = get_chunker(*chunker_params, seed=self.key.chunk_seed, sparse=False)
def add(self, item):
self.buffer.write(self.packer.pack(item.as_dict()))
@ -2313,7 +2313,7 @@ class ArchiveRecreater:
cache=self.cache, key=self.key,
add_item=target.add_item, write_checkpoint=target.write_checkpoint,
checkpoint_interval=self.checkpoint_interval, rechunkify=target.recreate_rechunkify).process_file_chunks
target.chunker = get_chunker(*target.chunker_params, seed=self.key.chunk_seed)
target.chunker = get_chunker(*target.chunker_params, seed=self.key.chunk_seed, sparse=False)
return target
def create_target_archive(self, name):

View file

@ -2992,6 +2992,21 @@ class ArchiverTestCase(ArchiverTestCaseBase):
assert not int(self.cmd('list', self.repository_location + '::test1', 'input/large_file',
'--format', '{unique_chunks}'))
def test_recreate_fixed_rechunkify(self):
with open(os.path.join(self.input_path, 'file'), 'wb') as fd:
fd.write(b'a' * 8192)
self.cmd('init', '--encryption=repokey', self.repository_location)
self.cmd('create', '--chunker-params', '7,9,8,128', self.repository_location + '::test', 'input')
output = self.cmd('list', self.repository_location + '::test', 'input/file',
'--format', '{num_chunks}')
num_chunks = int(output)
assert num_chunks > 2
self.cmd('recreate', self.repository_location, '--chunker-params', 'fixed,4096')
output = self.cmd('list', self.repository_location + '::test', 'input/file',
'--format', '{num_chunks}')
num_chunks = int(output)
assert num_chunks == 2
def test_recreate_recompress(self):
self.create_regular_file('compressible', size=10000)
self.cmd('init', '--encryption=repokey', self.repository_location)