Give the system-prune CLI command a two-phase plan/execute report

Restructures the disk-cleanup command to show location, current on-disk
size, and an estimated reclaim per area (attachments, project files,
container workspaces) before touching anything - --dry-run stops there.
A real run re-executes each check, reports actual items/bytes freed,
an "After" size per area, and a final total with elapsed time, flagging
any drift between the estimate and execution passes (e.g. the live
server wrote something in between).

store.gc_workspaces() now reports bytes freed alongside the removed
count (previously count-only), so the containers gc-workspaces CLI
action picks up the same reporting for free.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W5tFWkm3UbcstcbPKFE5gP
This commit is contained in:
2026-09-08 05:07:31 +02:00
co-authored by Claude Sonnet 5
parent 3c69de9d55
commit 68a7c3b002
5 changed files with 193 additions and 49 deletions
+9 -4
View File
@@ -37,11 +37,13 @@ def test_gc_workspaces_removes_directories_with_no_live_instance(
orphan_project = "gcws-orphan-project"
(tmp_path / active_project).mkdir()
(tmp_path / orphan_project).mkdir()
(tmp_path / orphan_project / "leftover.bin").write_bytes(b"x" * 42)
_make_instance(active_project)
removed = store.gc_workspaces()
removed, freed = store.gc_workspaces()
assert removed == 1
assert freed == 42
assert (tmp_path / active_project).exists()
assert not (tmp_path / orphan_project).exists()
@@ -52,9 +54,10 @@ def test_gc_workspaces_ignores_soft_deleted_instances(local_db, tmp_path, monkey
(tmp_path / project).mkdir()
_make_instance(project, deleted_at="2020-01-01T00:00:00+00:00")
removed = store.gc_workspaces()
removed, freed = store.gc_workspaces()
assert removed == 1
assert freed == 0
assert not (tmp_path / project).exists()
@@ -62,10 +65,12 @@ def test_gc_workspaces_dry_run_changes_nothing(local_db, tmp_path, monkeypatch):
monkeypatch.setattr("devplacepy.config.CONTAINER_WORKSPACES_DIR", tmp_path)
orphan_project = "gcws-dry-run-project"
(tmp_path / orphan_project).mkdir()
(tmp_path / orphan_project / "leftover.bin").write_bytes(b"y" * 7)
removed = store.gc_workspaces(dry_run=True)
removed, freed = store.gc_workspaces(dry_run=True)
assert removed == 1
assert freed == 7
assert (tmp_path / orphan_project).exists()
@@ -73,4 +78,4 @@ def test_gc_workspaces_missing_base_dir_is_a_noop(local_db, tmp_path, monkeypatc
monkeypatch.setattr(
"devplacepy.config.CONTAINER_WORKSPACES_DIR", tmp_path / "does-not-exist"
)
assert store.gc_workspaces() == 0
assert store.gc_workspaces() == (0, 0)