Skip to content

Commit

Permalink
Updated download script
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-be committed Aug 24, 2020
1 parent a5f8b9f commit dd8c38b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/common/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ pub fn download_resource(resource: &Resource) -> Result<&PathBuf, RustBertError>
let local = task::LocalSet::new();
local.block_on(&mut rt, async {
let client = Client::new();
let mut output_file = tokio::fs::File::create(target).await?;
let mut response = client.get(url.as_str()).send().await?;
let output_file = tokio::fs::File::create(target).await?;
let mut output_file = tokio::io::BufWriter::new(output_file);
let mut response = client.get(&url).send().await?;
while let Some(chunk) = response.chunk().await? {
output_file.write_all(&chunk).await?;
output_file.write(&chunk).await?;
}
output_file.flush().await?;
Ok::<(), RustBertError>(())
})?;
}
Expand Down

0 comments on commit dd8c38b

Please sign in to comment.