Handle empty payloads

This commit is contained in:
Louis Dureuil 2025-01-16 18:28:43 +01:00
parent 289eb92bef
commit 11458eefd9
No known key found for this signature in database

View File

@ -2016,10 +2016,7 @@ impl<'a> Dump<'a> {
task: TaskDump,
content_file: Option<Box<UpdateFile>>,
) -> Result<Task> {
let task_has_no_docs = match task.kind {
KindDump::DocumentImport { documents_count, .. } if documents_count == 0 => true,
_ => false,
};
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 => {
@ -2040,9 +2037,7 @@ impl<'a> Dump<'a> {
// 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.create_update_file(false)?;
let builder = DocumentsBatchBuilder::new(&mut file);
builder.into_inner()?;
let (uuid, file) = self.index_scheduler.create_update_file(false)?;
file.persist()?;
Some(uuid)