Add snapshot_symlink property
This commit is contained in:
parent
ae08caa6be
commit
529a3b830d
@ -151,6 +151,14 @@ class Repository(Hierarchy):
|
|||||||
"""
|
"""
|
||||||
return self.path / "data"
|
return self.path / "data"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def snapshot_symlink(self):
|
||||||
|
"""
|
||||||
|
:return: the path of the symlink pointing to the most recent snapshot
|
||||||
|
:rtype: path-like object
|
||||||
|
"""
|
||||||
|
return self.path / "current"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def snapshots(self):
|
def snapshots(self):
|
||||||
"""
|
"""
|
||||||
@ -169,7 +177,7 @@ class Repository(Hierarchy):
|
|||||||
return not self.snapshots
|
return not self.snapshots
|
||||||
|
|
||||||
def cleanup(self, *, remove_snapshots=False, remove_repo_dir=False):
|
def cleanup(self, *, remove_snapshots=False, remove_repo_dir=False):
|
||||||
"""Clean up any filesystem references to this repository.
|
"""Remove this repository from the filesystem.
|
||||||
By default, no snapshots are deleted.
|
By default, no snapshots are deleted.
|
||||||
|
|
||||||
:param remove_snapshots: delete the data directory of this repository
|
:param remove_snapshots: delete the data directory of this repository
|
||||||
@ -188,6 +196,7 @@ class Repository(Hierarchy):
|
|||||||
syslog.debug("Cleaning repository data")
|
syslog.debug("Cleaning repository data")
|
||||||
|
|
||||||
self.metadata_path.unlink()
|
self.metadata_path.unlink()
|
||||||
|
self.snapshot_symlink.unlink()
|
||||||
syslog.info("Removing repository metadata")
|
syslog.info("Removing repository metadata")
|
||||||
syslog.debug(f"Repository metadata removed: {self.metadata_path}")
|
syslog.debug(f"Repository metadata removed: {self.metadata_path}")
|
||||||
|
|
||||||
@ -269,13 +278,11 @@ class Repository(Hierarchy):
|
|||||||
:param snapshot: the snapshot to create the symlink to
|
:param snapshot: the snapshot to create the symlink to
|
||||||
:type snapshot: Snapshot object
|
:type snapshot: Snapshot object
|
||||||
"""
|
"""
|
||||||
snapshot_symlink = self.path / "current"
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
snapshot_symlink.unlink()
|
self.snapshot_symlink.unlink()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
syslog.error(e)
|
syslog.error(e)
|
||||||
|
|
||||||
snapshot_symlink.symlink_to(snapshot)
|
self.snapshot_symlink.symlink_to(snapshot)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user