fix delete dataset when dataset has no document (#2789)

Co-authored-by: jyong <jyong@dify.ai>
This commit is contained in:
Jyong 2024-03-11 23:57:38 +08:00 committed by GitHub
parent e54c9cd401
commit 796c5626a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,6 +44,10 @@ def clean_dataset_task(dataset_id: str, tenant_id: str, indexing_technique: str,
documents = db.session.query(Document).filter(Document.dataset_id == dataset_id).all()
segments = db.session.query(DocumentSegment).filter(DocumentSegment.dataset_id == dataset_id).all()
if documents is None or len(documents) == 0:
logging.info(click.style('No documents found for dataset: {}'.format(dataset_id), fg='green'))
return
index_processor = IndexProcessorFactory(doc_form).init_index_processor()
index_processor.clean(dataset, None)