mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-22 07:43:06 +00:00
Merge pull request #8489 from ThomasWaldmann/fix-8485
lock after checking repo exists, fixes #8485
This commit is contained in:
commit
f7f2f23a7c
1 changed files with 3 additions and 4 deletions
|
@ -230,10 +230,6 @@ def open(self, *, exclusive, lock_wait=None, lock=True):
|
|||
raise self.DoesNotExist(str(self._location)) from None
|
||||
else:
|
||||
self.store_opened = True
|
||||
if lock:
|
||||
self.lock = Lock(self.store, exclusive, timeout=lock_wait).acquire()
|
||||
else:
|
||||
self.lock = None
|
||||
try:
|
||||
readme = self.store.load("config/readme").decode()
|
||||
except StoreObjectNotFound:
|
||||
|
@ -247,6 +243,9 @@ def open(self, *, exclusive, lock_wait=None, lock=True):
|
|||
str(self._location), "repository version %d is not supported by this borg version" % self.version
|
||||
)
|
||||
self.id = hex_to_bin(self.store.load("config/id").decode(), length=32)
|
||||
# important: lock *after* making sure that there actually is an existing, supported repository.
|
||||
if lock:
|
||||
self.lock = Lock(self.store, exclusive, timeout=lock_wait).acquire()
|
||||
self.opened = True
|
||||
|
||||
def close(self):
|
||||
|
|
Loading…
Reference in a new issue