From a83739fda81065418cdfddc5b9a77c553bf1d647 Mon Sep 17 00:00:00 2001 From: user062 <48716714+user062@users.noreply.github.com> Date: Wed, 20 Mar 2019 17:03:07 +0000 Subject: [PATCH] give invalid repo error msg if repo config not found, fixes #4411 if the repo config is not there, we definitely have a invalid repo. for other problems (like permission issues), we'll just let it blow up with a traceback, so the user can see what the precise problem is. --- src/borg/repository.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/borg/repository.py b/src/borg/repository.py index 1b0a20648..18995af9f 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -393,8 +393,12 @@ def open(self, path, exclusive, lock_wait=None, lock=True): else: self.lock = None self.config = ConfigParser(interpolation=None) - with open(os.path.join(self.path, 'config')) as fd: - self.config.read_file(fd) + try: + with open(os.path.join(self.path, 'config')) as fd: + self.config.read_file(fd) + except FileNotFoundError: + self.close() + raise self.InvalidRepository(self.path) if 'repository' not in self.config.sections() or self.config.getint('repository', 'version') != 1: self.close() raise self.InvalidRepository(path)