Skip to content

Commit c2658fa

Browse files
committed
feat: update file name for existing records based on sha256_hash and knowledge/document IDs
1 parent 056f79a commit c2658fa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

apps/knowledge/serializers/document.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,11 @@ def replace(self):
15691569
# 读取新文件内容
15701570
file_content = file.read()
15711571

1572+
QuerySet(File).filter(
1573+
sha256_hash=original_hash,
1574+
source_id__in=[self.data.get('knowledge_id'), self.data.get('document_id')]
1575+
).update(file_name=file.name)
1576+
15721577
# 查找所有具有相同sha256_hash的文件
15731578
files_to_update = QuerySet(File).filter(
15741579
sha256_hash=original_hash,

0 commit comments

Comments
 (0)