refactor: ZFS.destroy_snapshot
This commit is contained in:
+6
-7
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user