mirror of
https://github.com/natankeddem/bale.git
synced 2026-04-23 06:50:41 +00:00
improved hold management and display
This commit is contained in:
@@ -137,7 +137,7 @@ class Zfs:
|
||||
with_holds.append(_name)
|
||||
with_holds = " ".join(with_holds)
|
||||
else:
|
||||
with_holds = [snapshot]
|
||||
with_holds = snapshot
|
||||
if len(with_holds) > 0:
|
||||
result = await self.execute(f"zfs holds -H -r {with_holds}", notify=False)
|
||||
tags: Dict[str, list[str]] = {}
|
||||
@@ -149,11 +149,16 @@ class Zfs:
|
||||
if s not in tags:
|
||||
tags[s] = []
|
||||
tags[s].append(md["tag"])
|
||||
self._last_data[query] = tags
|
||||
if snapshot in self._last_data[query]:
|
||||
result.data = self._last_data[query][snapshot]
|
||||
if query not in self._last_data:
|
||||
self._last_data[query] = {}
|
||||
self._last_data[query].update(tags)
|
||||
if snapshot is None:
|
||||
result.data = self._last_data[query]
|
||||
else:
|
||||
result.data = []
|
||||
if snapshot in self._last_data[query]:
|
||||
result.data = self._last_data[query][snapshot]
|
||||
else:
|
||||
result.data = []
|
||||
else:
|
||||
return Result(data=[])
|
||||
else:
|
||||
@@ -227,6 +232,7 @@ class Zfs:
|
||||
md["creation_date"] = datetime.fromtimestamp(md["creation"]).strftime("%Y/%m/%d")
|
||||
md["creation_time"] = datetime.fromtimestamp(md["creation"]).strftime("%H:%M")
|
||||
md["used"] = format_bytes(md["used_bytes"])
|
||||
md["userrefs"] = int(md["userrefs"])
|
||||
snapshot = f"{md['filesystem']}@{md['name']}"
|
||||
snapshots[snapshot] = md
|
||||
self._last_data[query] = snapshots
|
||||
|
||||
@@ -259,32 +259,34 @@ class Manage(Tab):
|
||||
if result == "confirm":
|
||||
self._spinner.visible = True
|
||||
rows = await self._grid.get_selected_rows()
|
||||
for row in rows:
|
||||
holds = await self.zfs.holds_for_snapshot(f"{row['filesystem']}@{row['name']}")
|
||||
for tag in holds.data:
|
||||
if tag not in all_tags:
|
||||
all_tags.append(tag)
|
||||
if len(all_tags) > 0:
|
||||
tags.update()
|
||||
self._spinner.visible = False
|
||||
result = await dialog
|
||||
if result == "release":
|
||||
if len(tags.value) > 0:
|
||||
for tag in tags.value:
|
||||
for row in rows:
|
||||
tasks = self._add_task(
|
||||
"release",
|
||||
zfs.SnapshotRelease(
|
||||
name=f"{row['filesystem']}@{row['name']}",
|
||||
tag=tag,
|
||||
recursive=recursive.value,
|
||||
).command,
|
||||
hosts=zfs_hosts.value,
|
||||
)
|
||||
if self._auto.value is True:
|
||||
for task in tasks:
|
||||
await self._run_task(task=task, spinner=self._spinner)
|
||||
await self.display_snapshots()
|
||||
if len(rows) > 0:
|
||||
for row in rows:
|
||||
holds = await self.zfs.holds_for_snapshot(f"{row['filesystem']}@{row['name']}")
|
||||
for tag in holds.data:
|
||||
if tag not in all_tags:
|
||||
all_tags.append(tag)
|
||||
if len(all_tags) > 0:
|
||||
tags.update()
|
||||
self._spinner.visible = False
|
||||
result = await dialog
|
||||
if result == "release":
|
||||
if len(tags.value) > 0:
|
||||
for tag in tags.value:
|
||||
for row in rows:
|
||||
tasks = self._add_task(
|
||||
"release",
|
||||
zfs.SnapshotRelease(
|
||||
name=f"{row['filesystem']}@{row['name']}",
|
||||
tag=tag,
|
||||
recursive=recursive.value,
|
||||
).command,
|
||||
hosts=zfs_hosts.value,
|
||||
)
|
||||
if self._auto.value is True:
|
||||
for task in tasks:
|
||||
await self._run_task(task=task, spinner=self._spinner)
|
||||
await self.display_snapshots()
|
||||
self._spinner.visible = False
|
||||
self._set_selection()
|
||||
|
||||
def _update_task_status(self, timestamp, status, result=None):
|
||||
|
||||
Reference in New Issue
Block a user