Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: change write to db order (#35948)

wangxiaoleic74cbb68da42
diff --git a/api/services/file_service.py b/api/services/file_service.py
index f60afe2f19d..b683a2f3d48 100644
--- a/api/services/file_service.py
+++ b/api/services/file_service.py
@@ -107,15 +107,14 @@ class FileService:
hash=hashlib.sha3_256(content).hexdigest(),
source_url=source_url,
)
- # The `UploadFile` ID is generated within its constructor, so flushing to retrieve the ID is unnecessary.
- # We can directly generate the `source_url` here before committing.
- if not upload_file.source_url:
- upload_file.source_url = file_helpers.get_signed_file_url(upload_file_id=upload_file.id)
with self._session_maker(expire_on_commit=False) as session:
session.add(upload_file)
session.commit()
+ if not upload_file.source_url:
+ upload_file.source_url = file_helpers.get_signed_file_url(upload_file_id=upload_file.id)
+
return upload_file
@staticmethod