MCPcopy
hub / github.com/borgbackup/borg / open

Method open

src/borg/repository.py:251–275  ·  view source on GitHub ↗
(self, *, exclusive, lock_wait=None, lock=True)

Source from the content-addressed store, hash-verified

249 self.store.destroy()
250
251 def open(self, *, exclusive, lock_wait=None, lock=True):
252 assert lock_wait is not None
253 try:
254 self.store.open()
255 except StoreBackendDoesNotExist:
256 raise self.DoesNotExist(str(self._location)) from None
257 else:
258 self.store_opened = True
259 try:
260 readme = self.store.load("config/readme").decode()
261 except StoreObjectNotFound:
262 raise self.DoesNotExist(str(self._location)) from None
263 if readme != REPOSITORY_README:
264 raise self.InvalidRepository(str(self._location))
265 self.version = int(self.store.load("config/version").decode())
266 if self.version not in self.acceptable_repo_versions:
267 self.close()
268 raise self.InvalidRepositoryConfig(
269 str(self._location), "repository version %d is not supported by this borg version" % self.version
270 )
271 self.id = hex_to_bin(self.store.load("config/id").decode(), length=32)
272 # important: lock *after* making sure that there actually is an existing, supported repository.
273 if lock:
274 self.lock = Lock(self.store, exclusive, timeout=lock_wait).acquire()
275 self.opened = True
276
277 def close(self):
278 if self.lock:

Callers 2

__enter__Method · 0.95
createMethod · 0.45

Calls 5

closeMethod · 0.95
hex_to_binFunction · 0.85
LockClass · 0.70
loadMethod · 0.45
acquireMethod · 0.45

Tested by

no test coverage detected