mirror of
https://github.com/borgbackup/borg.git
synced 2026-05-28 04:03:21 -04:00
config: accept non-int value for max_segment_size
borg config REPO max_segment_size 500M note: when setting a non-int value for this in a repo config, using the repo will require borg >= 1.1.16.
This commit is contained in:
parent
99aa15b850
commit
d44836a865
2 changed files with 6 additions and 6 deletions
|
|
@ -1744,16 +1744,13 @@ class Archiver:
|
|||
def repo_validate(section, name, value=None, check_value=True):
|
||||
if section not in ['repository', ]:
|
||||
raise ValueError('Invalid section')
|
||||
if name in ['segments_per_dir', 'max_segment_size', 'last_segment_checked', ]:
|
||||
if name in ['segments_per_dir', 'last_segment_checked', ]:
|
||||
if check_value:
|
||||
try:
|
||||
int(value)
|
||||
except ValueError:
|
||||
raise ValueError('Invalid value') from None
|
||||
if name == 'max_segment_size':
|
||||
if int(value) >= MAX_SEGMENT_SIZE_LIMIT:
|
||||
raise ValueError('Invalid value: max_segment_size >= %d' % MAX_SEGMENT_SIZE_LIMIT)
|
||||
elif name in ['additional_free_space', 'storage_quota', ]:
|
||||
elif name in ['max_segment_size', 'additional_free_space', 'storage_quota', ]:
|
||||
if check_value:
|
||||
try:
|
||||
parse_file_size(value)
|
||||
|
|
@ -1762,6 +1759,9 @@ class Archiver:
|
|||
if name == 'storage_quota':
|
||||
if parse_file_size(value) < parse_file_size('10M'):
|
||||
raise ValueError('Invalid value: storage_quota < 10M')
|
||||
elif name == 'max_segment_size':
|
||||
if parse_file_size(value) >= MAX_SEGMENT_SIZE_LIMIT:
|
||||
raise ValueError('Invalid value: max_segment_size >= %d' % MAX_SEGMENT_SIZE_LIMIT)
|
||||
elif name in ['append_only', ]:
|
||||
if check_value and value not in ['0', '1']:
|
||||
raise ValueError('Invalid value')
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ class Repository:
|
|||
if 'repository' not in self.config.sections() or self.config.getint('repository', 'version') != 1:
|
||||
self.close()
|
||||
raise self.InvalidRepository(path)
|
||||
self.max_segment_size = self.config.getint('repository', 'max_segment_size')
|
||||
self.max_segment_size = parse_file_size(self.config.get('repository', 'max_segment_size'))
|
||||
if self.max_segment_size >= MAX_SEGMENT_SIZE_LIMIT:
|
||||
self.close()
|
||||
raise self.InvalidRepositoryConfig(path, 'max_segment_size >= %d' % MAX_SEGMENT_SIZE_LIMIT) # issue 3592
|
||||
|
|
|
|||
Loading…
Reference in a new issue