diff --git a/rbackup/struct/hierarchy.py b/rbackup/struct/hierarchy.py index 5701958..dfe7ffe 100644 --- a/rbackup/struct/hierarchy.py +++ b/rbackup/struct/hierarchy.py @@ -48,6 +48,8 @@ class Hierarchy(PathLike): :type dest: str or path-like object """ self._path = Path(dest).resolve() + self._metadata_path = self._path / ".metadata" + self._name = self._path.name def __fspath__(self): return str(self._path) @@ -70,7 +72,7 @@ class Hierarchy(PathLike): :rtype: str """ - return self._path.name + return self._name @property def metadata_path(self): @@ -78,7 +80,7 @@ class Hierarchy(PathLike): :rtype: path-like object """ - return self._path / ".metadata" + return self._metadata_path def gen_metadata(self): """Generate metadata for this repository. diff --git a/rbackup/struct/snapshot.py b/rbackup/struct/snapshot.py index 2b9403c..1465b48 100644 --- a/rbackup/struct/snapshot.py +++ b/rbackup/struct/snapshot.py @@ -32,6 +32,8 @@ class Snapshot(Hierarchy): """Default constructor for the Snapshot class.""" super().__init__(path) + self._pkg_dir = self.path / "pkg" + def __repr__(self): """Return a string representation of this Snapshot.""" return f"{self.__class__.__name__}('{self.name}')" @@ -42,7 +44,7 @@ class Snapshot(Hierarchy): :rtype: path-like object """ - return self.path / "pkg" + return self._pkg_dir def gen_metadata(self): """Generate metadata for this repository.