Skip to content

Commit

Permalink
use the hash method not a copy paste of its code
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Sep 8, 2023
1 parent 3fc9d95 commit 2e2ca4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/cargo/sources/registry/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 6 additions & 13 deletions src/cargo/sources/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 2e2ca4c

Please sign in to comment.