mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 17:38:04 +08:00
feat(sandbox): refactor sandbox file handling to include app_id
- Updated API routes to use app_id instead of sandbox_id for file operations, aligning with user-specific sandbox workspaces. - Enhanced SandboxFileService and related classes to accommodate app_id in file listing and download functionalities. - Refactored storage key generation for sandbox archives to include app_id, ensuring proper file organization. - Adjusted frontend contracts and services to reflect the new app_id parameter in API calls.
This commit is contained in:
@ -10,8 +10,9 @@ from core.sandbox.manager import SandboxManager
|
||||
|
||||
|
||||
class SandboxFileBrowser:
|
||||
def __init__(self, *, tenant_id: str, sandbox_id: str):
|
||||
def __init__(self, *, tenant_id: str, app_id: str, sandbox_id: str):
|
||||
self._tenant_id = tenant_id
|
||||
self._app_id = app_id
|
||||
self._sandbox_id = sandbox_id
|
||||
|
||||
@staticmethod
|
||||
@ -30,10 +31,19 @@ class SandboxFileBrowser:
|
||||
return "." if normalized in (".", "") else normalized
|
||||
|
||||
def _backend(self) -> SandboxFileSource:
|
||||
runtime = SandboxManager.get(self._sandbox_id)
|
||||
if runtime is not None:
|
||||
return SandboxFileRuntimeSource(tenant_id=self._tenant_id, sandbox_id=self._sandbox_id, runtime=runtime)
|
||||
return SandboxFileArchiveSource(tenant_id=self._tenant_id, sandbox_id=self._sandbox_id)
|
||||
sandbox = SandboxManager.get(self._sandbox_id)
|
||||
if sandbox is not None:
|
||||
return SandboxFileRuntimeSource(
|
||||
tenant_id=self._tenant_id,
|
||||
app_id=self._app_id,
|
||||
sandbox_id=self._sandbox_id,
|
||||
runtime=sandbox.vm,
|
||||
)
|
||||
return SandboxFileArchiveSource(
|
||||
tenant_id=self._tenant_id,
|
||||
app_id=self._app_id,
|
||||
sandbox_id=self._sandbox_id,
|
||||
)
|
||||
|
||||
def exists(self) -> bool:
|
||||
"""Check if the sandbox source exists and is available."""
|
||||
|
||||
Reference in New Issue
Block a user