Explorar el Código

Merge pull request #4461 from user062/patch-2

give invalid repo error msg if repo config not found, fixes #4411
TW hace 6 años
padre
commit
8c4cedc7f4
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. 6 2
      src/borg/repository.py

+ 6 - 2
src/borg/repository.py

@@ -393,8 +393,12 @@ class Repository:
         else:
         else:
             self.lock = None
             self.lock = None
         self.config = ConfigParser(interpolation=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:
         if 'repository' not in self.config.sections() or self.config.getint('repository', 'version') != 1:
             self.close()
             self.close()
             raise self.InvalidRepository(path)
             raise self.InvalidRepository(path)