mirror of
https://github.com/langgenius/dify.git
synced 2026-03-20 22:17:58 +08:00
- 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.
34 lines
994 B
Python
34 lines
994 B
Python
from __future__ import annotations
|
|
|
|
import abc
|
|
|
|
from core.sandbox.entities.files import SandboxFileDownloadTicket, SandboxFileNode
|
|
|
|
|
|
class SandboxFileSource(abc.ABC):
|
|
_LIST_TIMEOUT_SECONDS = 30
|
|
_UPLOAD_TIMEOUT_SECONDS = 60 * 10
|
|
_EXPORT_EXPIRES_IN_SECONDS = 60 * 10
|
|
|
|
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
|
|
|
|
@abc.abstractmethod
|
|
def exists(self) -> bool:
|
|
"""Check if the sandbox source exists and is available.
|
|
|
|
Returns:
|
|
True if the sandbox source exists and can be accessed, False otherwise.
|
|
"""
|
|
raise NotImplementedError
|
|
|
|
@abc.abstractmethod
|
|
def list_files(self, *, path: str, recursive: bool) -> list[SandboxFileNode]:
|
|
raise NotImplementedError
|
|
|
|
@abc.abstractmethod
|
|
def download_file(self, *, path: str) -> SandboxFileDownloadTicket:
|
|
raise NotImplementedError
|