mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-04 16:22:55 +00:00
Compare commits
1 Commits
fastfieldc
...
issue/866b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37e7af322d |
@@ -23,6 +23,7 @@ memmap = {version = "0.7", optional=true}
|
|||||||
lz4 = {version="1.20", optional=true}
|
lz4 = {version="1.20", optional=true}
|
||||||
snap = "1"
|
snap = "1"
|
||||||
tempfile = {version="3.0", optional=true}
|
tempfile = {version="3.0", optional=true}
|
||||||
|
atomicwrites = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
serde = {version="1.0", features=["derive"]}
|
serde = {version="1.0", features=["derive"]}
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::core::META_FILEPATH;
|
use crate::core::META_FILEPATH;
|
||||||
|
use atomicwrites;
|
||||||
use crate::directory::error::LockError;
|
use crate::directory::error::LockError;
|
||||||
use crate::directory::error::{
|
use crate::directory::error::{
|
||||||
DeleteError, IOError, OpenDirectoryError, OpenReadError, OpenWriteError,
|
DeleteError, IOError, OpenDirectoryError, OpenReadError, OpenWriteError,
|
||||||
@@ -490,11 +491,9 @@ impl Directory for MmapDirectory {
|
|||||||
|
|
||||||
fn atomic_write(&mut self, path: &Path, content: &[u8]) -> io::Result<()> {
|
fn atomic_write(&mut self, path: &Path, content: &[u8]) -> io::Result<()> {
|
||||||
debug!("Atomic Write {:?}", path);
|
debug!("Atomic Write {:?}", path);
|
||||||
let mut tempfile = tempfile::Builder::new().tempfile_in(&self.inner.root_path)?;
|
|
||||||
tempfile.write_all(content)?;
|
|
||||||
tempfile.flush()?;
|
|
||||||
let full_path = self.resolve_path(path);
|
let full_path = self.resolve_path(path);
|
||||||
tempfile.into_temp_path().persist(full_path)?;
|
let meta_file = atomicwrites::AtomicFile::new(full_path, atomicwrites::AllowOverwrite);
|
||||||
|
meta_file.write(|f| f.write_all(content))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user