From 2f6197df0cfdb511f59bd51f325c32aa41d7ddc2 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 27 Sep 2022 21:45:37 +0200 Subject: [PATCH 1/2] add test for recreate with "fixed" chunker --- src/borg/testsuite/archiver.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index 0e4752662..161469b85 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -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) From 875c94a20d68d4efd14ed5ebd36260671165aedb Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 27 Sep 2022 19:36:52 +0200 Subject: [PATCH 2/2] get_chunker: fix missing sparse=False argument, fixes #7056 --- src/borg/archive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 8cd261ad4..5d9d97072 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -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):