Fix: list_snapshots mit -r statt -d1, Cache-Key pro Dataset

-d 1 begrenzte auf direkte Snapshots des Datasets, tank/share wurde
nicht eingeschlossen. -r (recursive) liefert alle Sub-Datasets.
Cache-Key jetzt dataset-spezifisch um Kollisionen zu vermeiden.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 22:59:40 +02:00
parent 9cc9844f0b
commit e3b42caf01
+5 -5
View File
@@ -362,16 +362,16 @@ class ZFSRunner:
""" """
List snapshots (with limit for performance on many snapshots) List snapshots (with limit for performance on many snapshots)
""" """
cached = self.cache.get("snapshots") cache_key = f"snapshots:{dataset_name or '*'}"
cached = self.cache.get(cache_key)
if cached: if cached:
return cached return cached
# If no dataset specified, list all
if dataset_name: if dataset_name:
cmd = ["zfs", "list", "-t", "snapshot", "-d", "1", "-H", "-p", # No -d limit so sub-datasets (e.g. tank/share) are included
cmd = ["zfs", "list", "-t", "snapshot", "-r", "-H", "-p",
"-o", "name,used,referenced,creation", dataset_name] "-o", "name,used,referenced,creation", dataset_name]
else: else:
# Get all snapshots, limited
cmd = ["zfs", "list", "-t", "snapshot", "-H", "-p", cmd = ["zfs", "list", "-t", "snapshot", "-H", "-p",
"-o", "name,used,referenced,creation"] "-o", "name,used,referenced,creation"]
@@ -402,7 +402,7 @@ class ZFSRunner:
snapshots.sort(key=lambda x: x["creation"], reverse=True) snapshots.sort(key=lambda x: x["creation"], reverse=True)
snapshots = snapshots[:limit] snapshots = snapshots[:limit]
self.cache.set("snapshots", snapshots, ttl_seconds=60) self.cache.set(cache_key, snapshots, ttl_seconds=60)
return snapshots return snapshots
def create_snapshot(self, dataset_name: str, snapshot_name: Optional[str] = None) -> Dict[str, str]: def create_snapshot(self, dataset_name: str, snapshot_name: Optional[str] = None) -> Dict[str, str]: