1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

set repository._location only

This commit is contained in:
Thomas Waldmann 2024-08-25 01:53:03 +02:00
parent 3408e942de
commit 1a382a8bcf
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 7 additions and 8 deletions

View file

@ -100,10 +100,9 @@ def __init__(
else:
url = "file://%s" % os.path.abspath(path_or_location)
location = Location(url)
self.location = location
self._location = location
# use a Store with flat config storage and 2-levels-nested data storage
self.store = Store(url, levels={"config/": [0], "data/": [2]})
self._location = Location(url)
self.version = None
# long-running repository methods which emit log or progress output are responsible for calling
# the ._send_log method periodically to get log and progress output transferred to the borg client
@ -123,7 +122,7 @@ def __init__(
self.exclusive = exclusive
def __repr__(self):
return f"<{self.__class__.__name__} {self.location}>"
return f"<{self.__class__.__name__} {self._location}>"
def __enter__(self):
if self.do_create:
@ -184,12 +183,12 @@ def open(self, *, exclusive, lock_wait=None, lock=True):
self.lock = None
readme = self.store.load("config/readme").decode()
if readme != REPOSITORY_README:
raise self.InvalidRepository(str(self.location))
raise self.InvalidRepository(str(self._location))
self.version = int(self.store.load("config/version").decode())
if self.version not in self.acceptable_repo_versions:
self.close()
raise self.InvalidRepositoryConfig(
str(self.location), "repository version %d is not supported by this borg version" % self.version
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)
self.opened = True
@ -346,7 +345,7 @@ def get(self, id, read_data=True):
raise IntegrityError(f"Object too small [id {id_hex}]: expected {meta_size}, got {len(meta)} bytes")
return hdr + meta
except StoreObjectNotFound:
raise self.ObjectNotFound(id, str(self.location)) from None
raise self.ObjectNotFound(id, str(self._location)) from None
def get_many(self, ids, read_data=True, is_preloaded=False):
for id_ in ids:
@ -377,7 +376,7 @@ def delete(self, id, wait=True):
try:
self.store.delete(key)
except StoreObjectNotFound:
raise self.ObjectNotFound(id, str(self.location)) from None
raise self.ObjectNotFound(id, str(self._location)) from None
def async_response(self, wait=True):
"""Get one async result (only applies to remote repositories).

View file

@ -44,7 +44,7 @@ def reopen(repository, exclusive: Optional[bool] = True, create=False):
if isinstance(repository, Repository):
if repository.opened:
raise RuntimeError("Repo must be closed before a reopen. Cannot support nested repository contexts.")
return Repository(repository.location, exclusive=exclusive, create=create)
return Repository(repository._location, exclusive=exclusive, create=create)
if isinstance(repository, RemoteRepository):
if repository.p is not None or repository.sock is not None: