TDB5HJSWMC6Q5RSH4NXZJWP2XAEOF75CXXOKSIG35NCMX75YDUWQC
2PCWN3KWPCSPLKGKZ553CBIYDEEBI6WDCKVRE2ZH2Z74LRTFD25AC
D6UTHZA4XNAR2PTG4YEZFNNH3OTSNOWGDSVBYDRE5R2YSV7MPN6AC
use std::io::Seek;
let size = usize::try_from(file.metadata()?.len()).expect("file should be smaller than usize::MAX");
let size =
usize::try_from(file.metadata()?.len()).expect("file should be smaller than usize::MAX");
let buffer_len = u64::try_from(buffer.len()).expect("should always work"); let file_size = file.metadata()?.len();
let buffer_len = u64::try_from(buffer.len()).expect("should always work");
let file_size = file.metadata()?.len();
if buffer.len() == size { let mut current_contents = Vec::with_capacity(size);
if buffer.len() == size {
let mut current_contents = Vec::with_capacity(size);
if buffer_len == file_size { let mut current_contents = Vec::with_capacity(buffer.len());
if buffer_len == file_size {
let mut current_contents = Vec::with_capacity(buffer.len());
// Ensure cursor points to beginning of file file.rewind()?;
// Ensure cursor points to beginning of file
file.rewind()?;
file.set_len(u64::try_from(buffer.len()).expect("should always work"))
file.set_len(buffer_len)?; file.sync_all()?; tracing::debug!(%path, "successfully wrote account file"); Ok(())
file.set_len(buffer_len)?;
file.sync_all()?;
tracing::debug!(%path, "successfully wrote account file");
Ok(())