Merge pull request #6618 from ThomasWaldmann/invalid-repo-msg-1.2

better error msg for defect or unsupported repo configs, fixes #6566
This commit is contained in:
TW 2022-04-18 09:52:52 +02:00 committed by GitHub
commit 390b3127d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -439,9 +439,16 @@ class Repository:
except FileNotFoundError:
self.close()
raise self.InvalidRepository(self.path)
if 'repository' not in self.config.sections() or self.config.getint('repository', 'version') != 1:
if 'repository' not in self.config.sections():
self.close()
raise self.InvalidRepository(path)
raise self.InvalidRepositoryConfig(path, 'no repository section found')
repo_version = self.config.getint('repository', 'version')
if repo_version != 1:
self.close()
raise self.InvalidRepositoryConfig(
path,
'repository version %d is not supported by this borg version' % repo_version
)
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()