Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/borg/helpers/parseformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ def ChunkerParams(s):
raise argparse.ArgumentTypeError('min. chunk size exponent must not be less than 6 (2^6 = 64B min. chunk size)')
if chunk_max > 23:
raise argparse.ArgumentTypeError('max. chunk size exponent must not be more than 23 (2^23 = 8MiB max. chunk size)')
# the chunker needs the hash window plus one byte beyond the min. chunk size to fit into
# a max. chunk size sized buffer, see the assertion in Chunker.__cinit__.
if window_size + 2 ** chunk_min + 1 > 2 ** chunk_max:
raise argparse.ArgumentTypeError('required: window_size + 2^chunk_min + 1 <= 2^chunk_max')
if window_size % 2 == 0:
raise argparse.ArgumentTypeError("window_size must be an uneven (odd) number")
return CH_BUZHASH, chunk_min, chunk_max, chunk_mask, window_size
Expand Down
5 changes: 5 additions & 0 deletions src/borg/testsuite/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ def test_chunkerparams():
ChunkerParams('buzhash,5,7,6,4095') # too small min. size
with pytest.raises(ArgumentTypeError):
ChunkerParams('buzhash,19,24,21,4095') # too big max. size
with pytest.raises(ArgumentTypeError):
ChunkerParams('buzhash,10,12,11,4095') # window_size + 2^chunk_min + 1 > 2^chunk_max
with pytest.raises(ArgumentTypeError):
ChunkerParams('19,19,19,4095') # dito, chunk_min == chunk_max
assert ChunkerParams('10,13,11,4095') == ('buzhash', 10, 13, 11, 4095) # just fits: 4095 + 1024 + 1 <= 8192
if borg2:
with pytest.raises(ArgumentTypeError):
ChunkerParams('buzhash,23,19,21,4095') # violates min <= mask <= max
Expand Down
Loading