Skip to content

Commit

Permalink
We need to actually flush the async File to ensure everything gets wr…
Browse files Browse the repository at this point in the history
…itten.

The `Drop` impl won't do it for us
  • Loading branch information
oli-obk committed Nov 29, 2023
1 parent f498d58 commit c80331d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/http_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ impl AssetReader for HttpAssetReader {
// Write asset to cache, but ensure only one HttpAssetReader writes at any given point in time
if self.sync.write().unwrap().insert(cache_path.clone()) {
async_fs::create_dir_all(cache_path.parent().unwrap()).await?;
File::create(&cache_path).await?.write_all(&bytes).await?;
let mut file = File::create(&cache_path).await?;
file.write_all(&bytes).await?;
file.flush().await?;
}
}
Ok(Box::new(VecReader::new(bytes)) as Box<Reader<'static>>)
Expand Down

0 comments on commit c80331d

Please sign in to comment.