Skip to content

Commit

Permalink
Merge pull request #8489 from ThomasWaldmann/fix-8485
Browse files Browse the repository at this point in the history
lock after checking repo exists, fixes #8485
  • Loading branch information
ThomasWaldmann authored Oct 24, 2024
2 parents 44aab3f + 9130baf commit f7f2f23
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/borg/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit f7f2f23

Please sign in to comment.