Skip to content

Commit

Permalink
adjust atomic rewrite on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Dec 9, 2023
1 parent 8d33974 commit b12f1e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ pub fn rewrite_atomic<P: AsRef<Path>>(path: P, content: &[u8]) -> std::io::Resul
let path = path.as_ref();
let folder = path.parent().expect("should have parent folder");

let mut temp_file = tempfile::NamedTempFile::new_in(folder)?;
temp_file.write_all(content)?;
temp_file.persist(path)?;

#[cfg(not(target_os = "windows"))]
{
let mut temp_file = tempfile::NamedTempFile::new_in(folder)?;
temp_file.write_all(content)?;
temp_file.persist(path)?;
// TODO: Not sure if the fsync is really required, but just for the sake of it...
let file = File::open(path)?;
file.sync_all()?;
}

// TODO: Not sure if the fsync is really required, but just for the sake of it...
let file = File::open(path)?;
file.sync_all()?;

Ok(())
}

Expand Down
1 change: 0 additions & 1 deletion src/levels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub struct Levels {
segments: HashMap<String, Arc<Segment>>,
levels: Vec<Level>,

//writer: BufWriter<File>,
/// Set of segment IDs that are masked
///
/// While consuming segments (because of compaction) they will not appear in the list of segments
Expand Down

0 comments on commit b12f1e9

Please sign in to comment.