mirror of https://github.com/langgenius/dify.git
1013 B
1013 B
Purpose
api/services/dataset_service.py hosts dataset/document service logic used by console and API controllers.
Batch document operations
- Batch document workflows should avoid N+1 database queries by using set-based lookups.
- Tenant checks must be enforced consistently across dataset/document operations.
DocumentService.get_documents_by_ids(...)fetches documents for a dataset usingid.in_(...).FileService.get_upload_files_by_ids(...)performs tenant-scoped batch lookup forUploadFile(dedupes ids withset(...)).DocumentService.get_document_download_url(...)andprepare_document_batch_download_zip(...)handle dataset/document permission checks plusDocument -> UploadFilevalidation for download endpoints.
Verification plan
- Exercise document list and download endpoints that use the service helpers.
- Confirm batch download uses constant query count for documents + upload files.
- Request a ZIP with a missing document id and confirm a 404 is returned.