Skip to content

Commit aaed0f0

Browse files
nepetcdecker
authored andcommitted
cli: Add I/O sync to filesystem
A flush is not needed here as `File` utilizes Os memory (afaict) which will write to the fs once we drop the `File`. We still a manual `sync_all()` to catch any errors that could arise writing to the fs that we would miss if we just drop the `File`. Signed-off-by: Peter Neuroth <[email protected]>
1 parent 41370a0 commit aaed0f0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libs/gl-cli/src/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn write_seed(file_path: impl AsRef<Path>, seed: impl AsRef<[u8]>) -> Result
3434

3535
let mut file = File::create(file_path)?;
3636
file.write_all(seed.as_ref())?;
37+
file.sync_all()?;
3738

3839
Ok(())
3940
}
@@ -43,6 +44,7 @@ pub fn write_seed(file_path: impl AsRef<Path>, seed: impl AsRef<[u8]>) -> Result
4344
pub fn write_credentials(file_path: impl AsRef<Path>, creds: impl AsRef<[u8]>) -> Result<()> {
4445
let mut file = File::create(&file_path)?;
4546
file.write_all(creds.as_ref())?;
47+
file.sync_all()?;
4648

4749
Ok(())
4850
}

0 commit comments

Comments
 (0)