delete draft workspace!

This commit is contained in:
lda
2026-05-19 05:58:50 +07:00 Verified
parent 8921fffc55
commit 4fac6d06d2
10 changed files with 102 additions and 0 deletions
@@ -50,6 +50,9 @@ class DraftWorkspaceStore:
def list_workspaces(self) -> list[WorkflowDraftWorkspace]:
raise NotImplementedError
def delete_workspace(self, workspace_id: str) -> bool:
raise NotImplementedError
class FileDraftWorkspaceStore(DraftWorkspaceStore):
"""JSON file-backed draft workspace store for local development and tests.
@@ -113,6 +116,14 @@ class FileDraftWorkspaceStore(DraftWorkspaceStore):
for path in sorted(self.workspaces_dir.glob("*.json"))
]
def delete_workspace(self, workspace_id: str) -> bool:
with self._lock:
path = self._workspace_path(workspace_id)
if not path.exists():
return False
path.unlink()
return True
def _workspace_path(self, workspace_id: str) -> Path:
safe_id = ensure_workspace_id(workspace_id)
root = self.workspaces_dir.resolve()