mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-06 01:02:55 +00:00
Bugfix: adds missing fdatasync on atomic_write.
In addition this PR: - removes unnecessary flushes and fsyncs on files. - replace all fsync by fdatasync. The latter triggers a meta sync if a metadata required to read the file has changed. It is therefore sufficient for us. Closes #1224
This commit is contained in:
@@ -234,7 +234,7 @@ impl MmapDirectory {
|
||||
}
|
||||
|
||||
let fd = open_opts.open(&self.inner.root_path)?;
|
||||
fd.sync_all()?;
|
||||
fd.sync_data()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -288,8 +288,7 @@ impl Write for SafeFileWriter {
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
self.0.flush()?;
|
||||
self.0.sync_all()
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +300,9 @@ impl Seek for SafeFileWriter {
|
||||
|
||||
impl TerminatingWrite for SafeFileWriter {
|
||||
fn terminate_ref(&mut self, _: AntiCallToken) -> io::Result<()> {
|
||||
self.flush()
|
||||
self.0.flush()?;
|
||||
self.0.sync_data()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,6 +332,7 @@ pub(crate) fn atomic_write(path: &Path, content: &[u8]) -> io::Result<()> {
|
||||
let mut tempfile = tempfile::Builder::new().tempfile_in(&parent_path)?;
|
||||
tempfile.write_all(content)?;
|
||||
tempfile.flush()?;
|
||||
tempfile.as_file_mut().sync_data()?;
|
||||
tempfile.into_temp_path().persist(path)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user