From 366e871778a5efdbf74e4b0a5413558b0cac13da Mon Sep 17 00:00:00 2001 From: Jacob Finkelman Date: Mon, 11 Sep 2023 16:19:15 +0000 Subject: [PATCH] use the `hash` method not a copy paste of its code --- src/cargo/sources/registry/index.rs | 2 +- src/cargo/sources/registry/mod.rs | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index c4b753051..f4a7c17a8 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -430,7 +430,7 @@ impl<'cfg> RegistryIndex<'cfg> { /// /// Internally there's quite a few layer of caching to amortize this cost /// though since this method is called quite a lot on null builds in Cargo. - pub fn summaries<'a, 'b>( + fn summaries<'a, 'b>( &'a mut self, name: &str, req: &'b OptVersionReq, diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 2a7c59599..d8fc47ba9 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -208,9 +208,7 @@ use crate::sources::source::Source; use crate::sources::PathSource; use crate::util::hex; use crate::util::network::PollExt; -use crate::util::{ - restricted_names, CargoResult, Config, Filesystem, LimitErrorReader, OptVersionReq, -}; +use crate::util::{restricted_names, CargoResult, Config, Filesystem, LimitErrorReader}; /// The `.cargo-ok` file is used to track if the source is already unpacked. /// See [`RegistrySource::unpack_package`] for more. @@ -690,19 +688,14 @@ impl<'cfg> RegistrySource<'cfg> { // After we've loaded the package configure its summary's `checksum` // field with the checksum we know for this `PackageId`. - let req = OptVersionReq::exact(package.version()); - let summary_with_cksum = self + let cksum = self .index - .summaries(&package.name(), &req, &mut *self.ops)? + .hash(package, &mut *self.ops) .expect("a downloaded dep now pending!?") - .filter(|s| s.package_id().version() == package.version()) - .next() .expect("summary not found"); - if let Some(cksum) = summary_with_cksum.as_summary().checksum() { - pkg.manifest_mut() - .summary_mut() - .set_checksum(cksum.to_string()); - } + pkg.manifest_mut() + .summary_mut() + .set_checksum(cksum.to_string()); Ok(pkg) }