Do not explode on missing content file if the task has no docs

This commit is contained in:
Louis Dureuil 2025-01-16 16:54:44 +01:00
parent 8a9f952bda
commit 6383f8f19e
No known key found for this signature in database

View File

@ -2017,6 +2017,11 @@ impl<'a> Dump<'a> {
task: TaskDump, task: TaskDump,
content_file: Option<Box<UpdateFile>>, content_file: Option<Box<UpdateFile>>,
) -> Result<Task> { ) -> Result<Task> {
let task_has_no_docs = match task.kind {
KindDump::DocumentImport { documents_count, .. } if documents_count == 0 => true,
_ => false,
};
let content_uuid = match content_file { let content_uuid = match content_file {
Some(content_file) if task.status == Status::Enqueued => { Some(content_file) if task.status == Status::Enqueued => {
let (uuid, mut file) = self.index_scheduler.create_update_file(false)?; let (uuid, mut file) = self.index_scheduler.create_update_file(false)?;
@ -2032,6 +2037,14 @@ impl<'a> Dump<'a> {
// If the task isn't `Enqueued` then just generate a recognisable `Uuid` // If the task isn't `Enqueued` then just generate a recognisable `Uuid`
// in case we try to open it later. // in case we try to open it later.
_ if task.status != Status::Enqueued => Some(Uuid::nil()), _ 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.create_update_file(false)?;
let builder = DocumentsBatchBuilder::new(&mut file);
builder.into_inner()?;
file.persist()?;
Some(uuid)
}
_ => None, _ => None,
}; };