1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-22 07:43:06 +00:00

lock after checking repo exists, fixes #8485

This commit is contained in:
Thomas Waldmann 2024-10-24 00:05:29 +02:00
parent d510555b1b
commit 9130baf973
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -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):