mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
feat: add DB inline content cache for app asset draft files
Introduce app_asset_contents table as a read-through cache over S3 for text-like asset files (e.g. .md skill documents). This eliminates N individual S3 fetches during SkillBuilder builds — bulk_load pulls all content in a single SQL query with S3 fallback on miss. Key components: - CachedContentAccessor: DB-first read / dual-write / S3 fallback - AssetContentService: static DB operations (get, get_many, upsert, delete) - should_mirror(): single source of truth for extension-based policy - Alembic migration for app_asset_contents table Modified callers: - SkillBuilder uses accessor.bulk_load() instead of per-node S3 reads - AppAssetService.get/update_file_content route through accessor - delete_node cleans both DB cache and S3 - draft_app_assets_initializer uses should_mirror() instead of hardcoded .md
This commit is contained in:
@ -89,21 +89,6 @@ def test_asset_paths_draft_validation():
|
||||
AssetPaths.draft(tenant_id=tenant_id, app_id=app_id, node_id="not-a-uuid")
|
||||
|
||||
|
||||
def test_asset_paths_resolved_requires_node_id():
|
||||
"""Test that AssetPaths.resolved() requires a valid node_id."""
|
||||
tenant_id = str(uuid4())
|
||||
app_id = str(uuid4())
|
||||
assets_id = str(uuid4())
|
||||
|
||||
# Missing node_id should raise
|
||||
with pytest.raises(TypeError):
|
||||
AssetPaths.resolved(tenant_id, app_id, assets_id) # type: ignore[call-arg]
|
||||
|
||||
# Invalid node_id should raise
|
||||
with pytest.raises(ValueError, match="node_id must be a valid UUID"):
|
||||
AssetPaths.resolved(tenant_id, app_id, assets_id, node_id="not-a-uuid")
|
||||
|
||||
|
||||
# --- Storage key format tests (must match existing paths exactly) ---
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user