mirror of
https://github.com/langgenius/dify.git
synced 2026-03-15 11:57:10 +08:00
Merge AssetDownloadItem, AssetInlineItem into SandboxDownloadItem with optional 'content' field. All consumers now follow a clean pipeline: get items → accessor.resolve_items() → AppAssetService.to_download_items() → download Key changes: - SandboxDownloadItem gains content: bytes | None (entities.py) - ZipSandbox.download_items() handles both inline (base64 heredoc) and remote (curl) via a single pipeline — no structural branching - AssetDownloadService.build_download_script() takes unified list - CachedContentAccessor.resolve_items() batch-enriches items from DB (extension-agnostic, no 'if md' checks needed) - AppAssetService.to_download_items() converts AssetItem → SandboxDownloadItem - DraftAppAssetsInitializer, package_and_upload, export_bundle simplified - file_upload/node.py switched to SandboxDownloadItem - Deleted AssetDownloadItem and AssetInlineItem classes
40 lines
966 B
Python
40 lines
966 B
Python
"""Data classes for ZipSandbox file operations.
|
|
|
|
Separated from ``zip_sandbox.py`` so that lightweight consumers (tests,
|
|
shell-script builders) can import the types without pulling in the full
|
|
sandbox provider chain.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class SandboxDownloadItem:
|
|
"""Unified download/inline item for sandbox file operations.
|
|
|
|
For remote files, *url* is set and the item is fetched via ``curl``.
|
|
For inline content, *content* is set and the bytes are written directly
|
|
into the VM via ``upload_file`` — no network round-trip.
|
|
"""
|
|
|
|
path: str
|
|
url: str = ""
|
|
content: bytes | None = field(default=None, repr=False)
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class SandboxUploadItem:
|
|
"""Item for uploading: sandbox path -> URL."""
|
|
|
|
path: str
|
|
url: str
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class SandboxFile:
|
|
"""A handle to a file in the sandbox."""
|
|
|
|
path: str
|