diff --git a/zfs-backup.py b/zfs-backup.py index 69a889d..95ce5da 100755 --- a/zfs-backup.py +++ b/zfs-backup.py @@ -244,16 +244,15 @@ class ZFS: ] @staticmethod - # TODO must take a Snapshot object - def destroy(full_name, *, recursive=False): - # TODO condition must be "begins with" - # or better argument should be a ZFSPath - if config.local_pool_to_backup in full_name: + def destroy_snapshot(snapshot: Snapshot, *, recursive=False): + if not isinstance(snapshot, Snapshot): + raise TypeError("Can only destroy snapshots.") + if config.local_pool_to_backup == snapshot.pool: raise Exception(DELETE_IN_LOCAL_POOL) cmdline = [config.ZFS, "destroy"] if recursive: cmdline.append("-r") - cmdline.append(full_name) + cmdline.append(str(snapshot)) run_command(cmdline) @staticmethod @@ -477,7 +476,7 @@ class Snapshot: return bool(search(regex, str(self._path))) def destroy(self): - ZFS.destroy(str(self)) + ZFS.destroy_snapshot(self) @property def pool(self) -> str: