浏览代码

Merge pull request #4461 from user062/patch-2

give invalid repo error msg if repo config not found, fixes #4411
TW 6 年之前
父节点
当前提交
8c4cedc7f4
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/borg/repository.py

+ 6 - 2
src/borg/repository.py

@@ -393,8 +393,12 @@ class Repository:
         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)