refactor(sandbox): rename delete_storage to delete_draft_storage for clarity

- Updated the SandboxManager to rename the method for deleting storage to better reflect its purpose.
- Adjusted the WorkflowVariableCollectionApi to utilize the new method name.
- Improved error handling in ArchiveSandboxStorage's delete method to log exceptions during deletion.
This commit is contained in:
Harry 2026-01-23 00:12:20 +08:00
parent 2f01107b09
commit cbac914649
4 changed files with 6 additions and 5 deletions

View File

@ -252,7 +252,7 @@ class WorkflowVariableCollectionApi(Resource):
def delete(self, app_model: App):
# FIXME(Mairuis): move to SandboxArtifactService
current_user, _ = current_account_with_tenant()
SandboxManager.delete_storage(app_model.tenant_id, current_user.id)
SandboxManager.delete_draft_storage(app_model.tenant_id, current_user.id)
draft_var_srv = WorkflowDraftVariableService(
session=db.session(),
)

View File

@ -136,8 +136,7 @@ class SandboxManager:
return sandbox
@classmethod
def delete_storage(cls, tenant_id: str, user_id: str) -> None:
# FIXME(Mairuis): move to SandboxArtifactService
def delete_draft_storage(cls, tenant_id: str, user_id: str) -> None:
storage = ArchiveSandboxStorage(tenant_id, SandboxBuilder.draft_id(user_id))
storage.delete()

View File

@ -38,7 +38,7 @@ def _render_download_script(root_path: str, download_commands: str) -> str:
download_one() {{
file_path="$1"
url="$2"
dest="${{download_root}}${{file_path}}"
dest="${{download_root}}/${{file_path}}"
mkdir -p "$(dirname "${{dest}}")"
eval "${{download_cmd}}" || echo "${{file_path}}" >> "${{fail_log}}"
}}

View File

@ -87,6 +87,8 @@ class ArchiveSandboxStorage(SandboxStorage):
return storage.exists(self._storage_key)
def delete(self) -> None:
if self.exists():
try:
storage.delete(self._storage_key)
logger.info("Deleted archive for sandbox %s", self._sandbox_id)
except Exception:
logger.exception("Failed to delete archive for sandbox %s", self._sandbox_id)