Download backend/src/gateway/path_utils.py from yonagush/deerflow: direct link, hf CLI and curl.
- Browser
- Download file 904 Bytes
-
https://huggingface.co/spaces/yonagush/deerflow/resolve/main/backend/src/gateway/path_utils.py
- Command line
-
hf download hf://spaces/yonagush/deerflow/backend/src/gateway/path_utils.py
-
curl -L -o path_utils.py https://huggingface.co/spaces/yonagush/deerflow/resolve/main/backend/src/gateway/path_utils.py
904 Bytes
| """Shared path resolution for thread virtual paths (e.g. mnt/user-data/outputs/...).""" | |
| from pathlib import Path | |
| from fastapi import HTTPException | |
| from src.config.paths import get_paths | |
| def resolve_thread_virtual_path(thread_id: str, virtual_path: str) -> Path: | |
| """Resolve a virtual path to the actual filesystem path under thread user-data. | |
| Args: | |
| thread_id: The thread ID. | |
| virtual_path: The virtual path as seen inside the sandbox | |
| (e.g., /mnt/user-data/outputs/file.txt). | |
| Returns: | |
| The resolved filesystem path. | |
| Raises: | |
| HTTPException: If the path is invalid or outside allowed directories. | |
| """ | |
| try: | |
| return get_paths().resolve_virtual_path(thread_id, virtual_path) | |
| except ValueError as e: | |
| status = 403 if "traversal" in str(e) else 400 | |
| raise HTTPException(status_code=status, detail=str(e)) | |