fixed type bug in get_snapshots

This commit is contained in:
2026-06-14 13:38:14 -04:00
parent 48e9f0199d
commit d8e916dbe6
+5 -5
View File
@@ -108,7 +108,7 @@ class Dataset:
self.written = int(properties["written"]["value"])
self.xattr = properties["xattr"]["value"]
def get_snapshots(self) -> list[Snapshot] | None:
def get_snapshots(self) -> list[Snapshot]:
"""Get all snapshots from zfs and process then is test dicts of sets."""
snapshots_data = _zfs_list(f"zfs list -t snapshot -pHj {self.name} -o all")
@@ -125,10 +125,10 @@ class Dataset:
if return_code == 0:
return "snapshot created"
if snapshots := self.get_snapshots():
snapshot_names = {snapshot.name for snapshot in snapshots}
if snapshot_name in snapshot_names:
return f"Snapshot {snapshot_name} already exists for {self.name}"
snapshots = self.get_snapshots()
snapshot_names = {snapshot.name for snapshot in snapshots}
if snapshot_name in snapshot_names:
return f"Snapshot {snapshot_name} already exists for {self.name}"
return f"Failed to create snapshot {snapshot_name} for {self.name}"