Skip to content

Commit 366e871

Browse files
committed
use the hash method not a copy paste of its code
1 parent 423bf05 commit 366e871

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/cargo/sources/registry/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl<'cfg> RegistryIndex<'cfg> {
430430
///
431431
/// Internally there's quite a few layer of caching to amortize this cost
432432
/// though since this method is called quite a lot on null builds in Cargo.
433-
pub fn summaries<'a, 'b>(
433+
fn summaries<'a, 'b>(
434434
&'a mut self,
435435
name: &str,
436436
req: &'b OptVersionReq,

src/cargo/sources/registry/mod.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ use crate::sources::source::Source;
208208
use crate::sources::PathSource;
209209
use crate::util::hex;
210210
use crate::util::network::PollExt;
211-
use crate::util::{
212-
restricted_names, CargoResult, Config, Filesystem, LimitErrorReader, OptVersionReq,
213-
};
211+
use crate::util::{restricted_names, CargoResult, Config, Filesystem, LimitErrorReader};
214212

215213
/// The `.cargo-ok` file is used to track if the source is already unpacked.
216214
/// See [`RegistrySource::unpack_package`] for more.
@@ -690,19 +688,14 @@ impl<'cfg> RegistrySource<'cfg> {
690688

691689
// After we've loaded the package configure its summary's `checksum`
692690
// field with the checksum we know for this `PackageId`.
693-
let req = OptVersionReq::exact(package.version());
694-
let summary_with_cksum = self
691+
let cksum = self
695692
.index
696-
.summaries(&package.name(), &req, &mut *self.ops)?
693+
.hash(package, &mut *self.ops)
697694
.expect("a downloaded dep now pending!?")
698-
.filter(|s| s.package_id().version() == package.version())
699-
.next()
700695
.expect("summary not found");
701-
if let Some(cksum) = summary_with_cksum.as_summary().checksum() {
702-
pkg.manifest_mut()
703-
.summary_mut()
704-
.set_checksum(cksum.to_string());
705-
}
696+
pkg.manifest_mut()
697+
.summary_mut()
698+
.set_checksum(cksum.to_string());
706699

707700
Ok(pkg)
708701
}

0 commit comments

Comments
 (0)