1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-21 23:33:07 +00:00

Merge pull request #8489 from ThomasWaldmann/fix-8485

lock after checking repo exists, fixes #8485
This commit is contained in:
TW 2024-10-24 02:41:29 +02:00 committed by GitHub
commit f7f2f23a7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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