mirror of https://github.com/borgbackup/borg.git
ChunkerParams: fix parameter order
the parser for the --chunker-params argument had a wrong parameter order. fixed the order so it conforms to the help text and the docs. also added some tests for it and a text for the ValueError exception.
This commit is contained in:
parent
b180158876
commit
93a89d97fa
|
@ -277,12 +277,12 @@ def timestamp(s):
|
||||||
|
|
||||||
|
|
||||||
def ChunkerParams(s):
|
def ChunkerParams(s):
|
||||||
window_size, chunk_mask, chunk_min, chunk_max = s.split(',')
|
chunk_min, chunk_max, chunk_mask, window_size = s.split(',')
|
||||||
if int(chunk_max) > 23:
|
if int(chunk_max) > 23:
|
||||||
# do not go beyond 2**23 (8MB) chunk size now,
|
# do not go beyond 2**23 (8MB) chunk size now,
|
||||||
# COMPR_BUFFER can only cope with up to this size
|
# COMPR_BUFFER can only cope with up to this size
|
||||||
raise ValueError
|
raise ValueError('max. chunk size exponent must not be more than 23 (2^23 = 8MiB max. chunk size)')
|
||||||
return int(window_size), int(chunk_mask), int(chunk_min), int(chunk_max)
|
return int(chunk_min), int(chunk_max), int(chunk_mask), int(window_size)
|
||||||
|
|
||||||
|
|
||||||
def CompressionSpec(s):
|
def CompressionSpec(s):
|
||||||
|
|
|
@ -7,7 +7,7 @@ import msgpack
|
||||||
|
|
||||||
from ..helpers import adjust_patterns, exclude_path, Location, format_timedelta, ExcludePattern, make_path_safe, \
|
from ..helpers import adjust_patterns, exclude_path, Location, format_timedelta, ExcludePattern, make_path_safe, \
|
||||||
prune_within, prune_split, \
|
prune_within, prune_split, \
|
||||||
StableDict, int_to_bigint, bigint_to_int, parse_timestamp, CompressionSpec
|
StableDict, int_to_bigint, bigint_to_int, parse_timestamp, CompressionSpec, ChunkerParams
|
||||||
from . import BaseTestCase
|
from . import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,6 +129,13 @@ def test_compression_specs():
|
||||||
CompressionSpec('invalid')
|
CompressionSpec('invalid')
|
||||||
|
|
||||||
|
|
||||||
|
def test_chunkerparams():
|
||||||
|
assert ChunkerParams('19,23,21,4095') == (19, 23, 21, 4095)
|
||||||
|
assert ChunkerParams('10,23,16,4095') == (10, 23, 16, 4095)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
ChunkerParams('19,24,21,4095')
|
||||||
|
|
||||||
|
|
||||||
class MakePathSafeTestCase(BaseTestCase):
|
class MakePathSafeTestCase(BaseTestCase):
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
|
|
Loading…
Reference in New Issue