mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
feat: add exists method to sandbox sources for existence checks
- Implemented the `exists` method in `SandboxFileSource` and its subclasses to verify the availability of sandbox sources. - Updated `SandboxFileService` to utilize the new `exists` method for improved error handling when listing files and downloading files. - Removed the previous check for storage existence in `archive_source.py` and replaced it with the new method.
This commit is contained in:
@ -35,6 +35,10 @@ class SandboxFileBrowser:
|
||||
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)
|
||||
|
||||
def exists(self) -> bool:
|
||||
"""Check if the sandbox source exists and is available."""
|
||||
return self._backend().exists()
|
||||
|
||||
def list_files(self, *, path: str | None = None, recursive: bool = False) -> list[SandboxFileNode]:
|
||||
workspace_path = self._normalize_workspace_path(path)
|
||||
return self._backend().list_files(path=workspace_path, recursive=recursive)
|
||||
|
||||
Reference in New Issue
Block a user