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.

update empty document caused delete exist collection (#6392)

Jyong443e96777ba4
diff --git a/api/tasks/document_indexing_update_task.py b/api/tasks/document_indexing_update_task.py
index b27274be37e..f129d93de8d 100644
--- a/api/tasks/document_indexing_update_task.py
+++ b/api/tasks/document_indexing_update_task.py
@@ -46,14 +46,15 @@ def document_indexing_update_task(dataset_id: str, document_id: str):
index_processor = IndexProcessorFactory(index_type).init_index_processor()
segments = db.session.query(DocumentSegment).filter(DocumentSegment.document_id == document_id).all()
- index_node_ids = [segment.index_node_id for segment in segments]
+ if segments:
+ index_node_ids = [segment.index_node_id for segment in segments]
- # delete from vector index
- index_processor.clean(dataset, index_node_ids)
+ # delete from vector index
+ index_processor.clean(dataset, index_node_ids)
- for segment in segments:
- db.session.delete(segment)
- db.session.commit()
+ for segment in segments:
+ db.session.delete(segment)
+ db.session.commit()
end_at = time.perf_counter()
logging.info(
click.style('Cleaned document when document update data source or process rule: {} latency: {}'.format(document_id, end_at - start_at), fg='green'))