From ef13d392c7564ce7865a7642cf9ed0a57a19ce4e Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Thu, 18 Aug 2016 12:26:14 +0200 Subject: [PATCH] Cache: release lock if cache is invalid --- borg/cache.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/borg/cache.py b/borg/cache.py index 0cacb2a8b..763a262aa 100644 --- a/borg/cache.py +++ b/borg/cache.py @@ -137,9 +137,11 @@ def _do_open(self): cache_version = self.config.getint('cache', 'version') wanted_version = 1 if cache_version != wanted_version: + self.close() raise Exception('%s has unexpected cache version %d (wanted: %d).' % ( config_path, cache_version, wanted_version)) except configparser.NoSectionError: + self.close() raise Exception('%s does not look like a Borg cache.' % config_path) from None self.id = self.config.get('cache', 'repository') self.manifest_id = unhexlify(self.config.get('cache', 'manifest'))