loop writing header while initializing

if somehow this doesn't finish in a single loop, do more just in case
This commit is contained in:
Pere Diaz Bou
2024-12-13 13:25:09 +01:00
parent 47d25292b2
commit 352b3540ee

View File

@@ -179,8 +179,17 @@ pub fn maybe_init_database_file(file: &Rc<dyn File>, io: &Arc<dyn IO>) -> Result
file.pwrite(0, contents.buffer.clone(), Rc::new(completion))
.unwrap();
}
io.run_once()?;
assert!(*flag_complete.borrow());
let mut limit = 100;
loop {
io.run_once()?;
if *flag_complete.borrow() {
break;
}
limit -= 1;
if limit == 0 {
panic!("Database file couldn't be initialized, io loop run for {} iterations and write didn't finish", limit);
}
}
}
};
Ok(())