mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 01:37:20 +00:00
remove deprecated "--compression <number>"
use --compression zlib,<number> instead in case of 0, you could also use --compression none
This commit is contained in:
parent
ad31fcd7c0
commit
3476fffe7d
2 changed files with 14 additions and 33 deletions
|
@ -466,35 +466,21 @@ def CompressionSpec(s):
|
|||
count = len(values)
|
||||
if count < 1:
|
||||
raise ValueError
|
||||
compression = values[0]
|
||||
try:
|
||||
compression = int(compression)
|
||||
if count > 1:
|
||||
raise ValueError
|
||||
# DEPRECATED: it is just --compression N
|
||||
if 0 <= compression <= 9:
|
||||
print('Warning: --compression %d is deprecated, please use --compression zlib,%d.' % (compression, compression))
|
||||
if compression == 0:
|
||||
print('Hint: instead of --compression zlib,0 you could also use --compression none for better performance.')
|
||||
print('Hint: archives generated using --compression none are not compatible with borg < 0.25.0.')
|
||||
return dict(name='zlib', level=compression)
|
||||
raise ValueError
|
||||
except ValueError:
|
||||
# --compression algo[,...]
|
||||
name = compression
|
||||
if name in ('none', 'lz4', ):
|
||||
return dict(name=name)
|
||||
if name in ('zlib', 'lzma', ):
|
||||
if count < 2:
|
||||
level = 6 # default compression level in py stdlib
|
||||
elif count == 2:
|
||||
level = int(values[1])
|
||||
if not 0 <= level <= 9:
|
||||
raise ValueError
|
||||
else:
|
||||
# --compression algo[,level]
|
||||
name = values[0]
|
||||
if name in ('none', 'lz4', ):
|
||||
return dict(name=name)
|
||||
if name in ('zlib', 'lzma', ):
|
||||
if count < 2:
|
||||
level = 6 # default compression level in py stdlib
|
||||
elif count == 2:
|
||||
level = int(values[1])
|
||||
if not 0 <= level <= 9:
|
||||
raise ValueError
|
||||
return dict(name=name, level=level)
|
||||
raise ValueError
|
||||
else:
|
||||
raise ValueError
|
||||
return dict(name=name, level=level)
|
||||
raise ValueError
|
||||
|
||||
|
||||
def dir_is_cachedir(path):
|
||||
|
|
|
@ -458,11 +458,6 @@ def test_pattern_matcher():
|
|||
def test_compression_specs():
|
||||
with pytest.raises(ValueError):
|
||||
CompressionSpec('')
|
||||
assert CompressionSpec('0') == dict(name='zlib', level=0)
|
||||
assert CompressionSpec('1') == dict(name='zlib', level=1)
|
||||
assert CompressionSpec('9') == dict(name='zlib', level=9)
|
||||
with pytest.raises(ValueError):
|
||||
CompressionSpec('10')
|
||||
assert CompressionSpec('none') == dict(name='none')
|
||||
assert CompressionSpec('lz4') == dict(name='lz4')
|
||||
assert CompressionSpec('zlib') == dict(name='zlib', level=6)
|
||||
|
|
Loading…
Reference in a new issue