Skip to content

Commit

Permalink
write entire buffer
Browse files Browse the repository at this point in the history
Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed Jun 12, 2024
1 parent 3027100 commit 19cb171
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions fs-storage/src/file_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,9 @@ where
})?;
fs::create_dir_all(parent_dir)?;
let mut file = File::create(&self.path)?;
// file.write_all(serde_json::to_string_pretty(&self.data)?.as_bytes())?;
// file.flush()?;
// // Sync the file to disk to ensure metadata is updated
// file.sync_all()?;

// use File::write
let data = serde_json::to_string_pretty(&self.data)?;
File::write(&mut file, data.as_bytes())?;
file.write_all(serde_json::to_string_pretty(&self.data)?.as_bytes())?;
file.flush()?;
// Sync the file to disk to ensure metadata is updated
file.sync_all()?;
drop(file);

Expand Down

0 comments on commit 19cb171

Please sign in to comment.