From 805531c90d78df85ca3d7a3be762bf545e5cf77a Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 16 Jan 2025 16:54:44 +0100 Subject: [PATCH] Do not explode on missing content file if the task has no docs --- crates/index-scheduler/src/dump.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/index-scheduler/src/dump.rs b/crates/index-scheduler/src/dump.rs index 643255ac2..ed3bb7c12 100644 --- a/crates/index-scheduler/src/dump.rs +++ b/crates/index-scheduler/src/dump.rs @@ -39,6 +39,8 @@ impl<'a> Dump<'a> { task: TaskDump, content_file: Option>, ) -> Result { + let task_has_no_docs = matches!(task.kind, KindDump::DocumentImport { documents_count, .. } if documents_count == 0); + let content_uuid = match content_file { Some(content_file) if task.status == Status::Enqueued => { let (uuid, mut file) = self.index_scheduler.queue.create_update_file(false)?; @@ -54,6 +56,14 @@ impl<'a> Dump<'a> { // If the task isn't `Enqueued` then just generate a recognisable `Uuid` // in case we try to open it later. _ if task.status != Status::Enqueued => Some(Uuid::nil()), + None if task.status == Status::Enqueued && task_has_no_docs => { + let (uuid, mut file) = self.index_scheduler.queue.create_update_file(false)?; + let builder = DocumentsBatchBuilder::new(&mut file); + builder.into_inner()?; + file.persist()?; + + Some(uuid) + } _ => None, };