From 6dd3fdbf567776647c97edfea34ca858281a1c80 Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Thu, 16 Apr 2026 21:59:26 -0500 Subject: [PATCH] fix: don't add to fresh until after download is complete This makes the sparse progress update work a little better. Previously it would display N completed, M pending, when N had not actually finished yet. With this change, N now ticks up exactly as M ticks down --- src/cargo/sources/registry/http_remote.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cargo/sources/registry/http_remote.rs b/src/cargo/sources/registry/http_remote.rs index c8b1ed2a3a3..cc38d8fed60 100644 --- a/src/cargo/sources/registry/http_remote.rs +++ b/src/cargo/sources/registry/http_remote.rs @@ -476,11 +476,6 @@ impl<'gctx> HttpBackend<'gctx> { if self.offline() { return Ok(LoadResponse::NotFound); } - - if !self.fresh.borrow_mut().insert(path.to_string()) { - warn!("downloaded the index file `{path}` twice"); - } - let mut r = Retry::new(self.gctx)?; self.pending.update(|v| v + 1); let response = loop { @@ -494,6 +489,9 @@ impl<'gctx> HttpBackend<'gctx> { } }; self.pending.update(|v| v - 1); + if !self.fresh.borrow_mut().insert(path.to_string()) { + warn!("downloaded the index file `{path}` twice"); + } response }