feat: add handling for missing source files in document processing
--bug=1062915 --user=刘瑞斌 【知识库】快速创建的文档,替换原文档报错,找不到源文件 https://www.tapd.cn/62980211/s/1789099v3.2
parent
a584378002
commit
096c72513f
|
|
@ -1538,8 +1538,15 @@ class DocumentSerializers(serializers.Serializer):
|
|||
source_file = QuerySet(File).filter(source_id=self.data.get('document_id')).first()
|
||||
|
||||
if not source_file:
|
||||
raise AppApiException(500, _('Source file not found'))
|
||||
|
||||
# 不存在手动关联一个文档
|
||||
new_source_file = File(
|
||||
id=uuid.uuid7(),
|
||||
file_name=file.name,
|
||||
source_type=FileSourceType.DOCUMENT,
|
||||
source_id=self.data.get('document_id'),
|
||||
)
|
||||
new_source_file.save(file.read())
|
||||
else:
|
||||
# 获取原文件的sha256_hash
|
||||
original_hash = source_file.sha256_hash
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue