apply most style comments of the review

This commit is contained in:
Tamo 2022-10-17 16:45:00 +02:00 committed by Clément Renault
parent dd70daaae3
commit 78ce29f461
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
7 changed files with 27 additions and 23 deletions

View file

@ -488,15 +488,22 @@ impl IndexScheduler {
Batch::Snapshot(_) => todo!(),
Batch::Dump(mut task) => {
let started_at = OffsetDateTime::now_utc();
let KindWithContent::DumpExport { keys, instance_uid, dump_uid } = &task.kind else {
let (keys, instance_uid, dump_uid) = if let KindWithContent::DumpExport {
keys,
instance_uid,
dump_uid,
} = &task.kind
{
(keys, instance_uid, dump_uid)
} else {
unreachable!();
};
let dump = dump::DumpWriter::new(instance_uid.clone())?;
let mut d_keys = dump.create_keys()?;
let mut dump_keys = dump.create_keys()?;
// 1. dump the keys
for key in keys {
d_keys.push_key(key)?;
dump_keys.push_key(key)?;
}
let rtxn = self.env.read_txn()?;
@ -575,8 +582,8 @@ impl IndexScheduler {
}
let path = self.dumps_path.join(format!("{}.dump", dump_uid));
let file = File::create(path).unwrap();
dump.persist_to(BufWriter::new(file)).unwrap();
let file = File::create(path)?;
dump.persist_to(BufWriter::new(file))?;
task.status = Status::Succeeded;

View file

@ -17,7 +17,6 @@ use meilisearch_types::tasks::{Kind, KindWithContent, Status, Task};
use meilisearch_types::InstanceUid;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::{Arc, RwLock};
use file_store::FileStore;
@ -397,7 +396,7 @@ impl IndexScheduler {
/// Register a new task comming from a dump in the scheduler.
/// By takinig a mutable ref we're pretty sure no one will ever import a dump while actix is running.
pub fn register_dumpped_task(
pub fn register_dumped_task(
&mut self,
task: TaskDump,
content_file: Option<Box<UpdateFile>>,
@ -421,9 +420,7 @@ impl IndexScheduler {
}
// 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::from_str("00112233-4455-6677-8899-aabbccddeeff").unwrap())
}
_ if task.status != Status::Enqueued => Some(Uuid::nil()),
_ => None,
};
@ -492,7 +489,7 @@ impl IndexScheduler {
};
self.all_tasks
.append(&mut wtxn, &BEU32::new(task.uid), &task)?;
.put(&mut wtxn, &BEU32::new(task.uid), &task)?;
if let Some(indexes) = task.indexes() {
for index in indexes {