Skip to content

Commit

Permalink
Auto merge of #3348 - alexcrichton:fix-checksums, r=brson
Browse files Browse the repository at this point in the history
Fix retrying crate downloads for network errors

Previously the `with_retry` loop was a little too tight where stale state about
the sha256 and data was kept out of the loop. Instead we need to reinitialize
these on each iteration of the loop to ensure that we correctly retry by
forgetting the data we previously downloaded for an aborted download attempt.
  • Loading branch information
bors committed Dec 2, 2016
2 parents 787591c + df30da0 commit 71a6cc9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cargo/sources/registry/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
handle.follow_location(true)?;
let mut state = Sha256::new();
let mut body = Vec::new();
{
network::with_retry(self.config, || {
state = Sha256::new();
body = Vec::new();
let mut handle = handle.transfer();
handle.write_function(|buf| {
state.update(buf);
body.extend_from_slice(buf);
Ok(buf.len())
})?;
network::with_retry(self.config, || {
handle.perform()
})?
}
handle.perform()
})?;
let code = handle.response_code()?;
if code != 200 && code != 0 {
bail!("failed to get 200 response from `{}`, got {}", url, code)
Expand Down

0 comments on commit 71a6cc9

Please sign in to comment.