mirror of
https://github.com/langgenius/dify.git
synced 2026-02-15 22:00:53 -05:00
- Introduced CachedPresignStorage to cache presigned download URLs, reducing repeated API calls. - Updated AppAssetService to utilize CachedPresignStorage for improved performance in asset download URL generation. - Refactored asset builders and packagers to support the new storage mechanism. - Removed unused AppAssetsAttrsInitializer to streamline initialization processes. - Added unit tests for CachedPresignStorage to ensure functionality and reliability.
28 lines
925 B
Python
28 lines
925 B
Python
from core.app.entities.app_asset_entities import AppAssetFileTree
|
|
from core.app_assets.entities import AssetItem
|
|
|
|
from .base import AssetBuilder, BuildContext
|
|
|
|
|
|
class AssetBuildPipeline:
|
|
_builders: list[AssetBuilder]
|
|
|
|
def __init__(self, builders: list[AssetBuilder]) -> None:
|
|
self._builders = builders
|
|
|
|
def build_all(self, tree: AppAssetFileTree, ctx: BuildContext) -> list[AssetItem]:
|
|
# 1. Distribute: each node goes to first accepting builder
|
|
for node in tree.walk_files():
|
|
path = tree.get_path(node.id)
|
|
for builder in self._builders:
|
|
if builder.accept(node):
|
|
builder.collect(node, path, ctx)
|
|
break
|
|
|
|
# 2. Each builder builds its collected nodes
|
|
results: list[AssetItem] = []
|
|
for builder in self._builders:
|
|
results.extend(builder.build(tree, ctx))
|
|
|
|
return results
|