Skip to content

Commit

Permalink
Requires flush?
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil committed Jan 7, 2025
1 parent dcbe07d commit 486a7f1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/api/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,16 +674,18 @@ impl ApiRepo {
}
}
println!("Truncating file {filename:?} to {length}");
let f = std::fs::OpenOptions::new()
let mut f = tokio::fs::OpenOptions::new()
.write(true)
.open(&filename)?;
.open(&filename).await?;
println!("Current size {:?}", f.metadata().await?.len());
f
.set_len(length as u64)?;
// let metadata = tokio::fs::OpenOptions::new()
// .write(true)
// .open(&filename)
// .await?.metadata().await?;
// assert_eq!(metadata.len(), length as u64);
.set_len(length as u64).await?;
f.flush().await?;
let metadata = tokio::fs::OpenOptions::new()
.write(true)
.open(&filename)
.await?.metadata().await?;
assert_eq!(metadata.len(), length as u64);

println!("Truncated file {filename:?} to {length}");
progressbar.finish().await;
Expand Down

0 comments on commit 486a7f1

Please sign in to comment.