Skip to content

Commit

Permalink
chore: refine the usage of PkgIdentity
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Dec 18, 2024
1 parent bdaed6f commit 14c94ff
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions core/src/ten_manager/src/dep_and_candidate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ fn clean_up_all_candidates(
all_candidates: &mut HashMap<PkgTypeName, HashSet<PkgInfo>>,
locked_pkgs: Option<&HashMap<PkgTypeName, PkgInfo>>,
) {
for (pkg_identity, pkg_infos) in all_candidates.iter_mut() {
for (pkg_type_name, pkg_infos) in all_candidates.iter_mut() {
let mut version_map: HashMap<Version, &PkgInfo> = HashMap::new();
let mut locked_pkgs_map: HashMap<Version, &PkgInfo> = HashMap::new();

let locked_pkg =
locked_pkgs.and_then(|locked_pkgs| locked_pkgs.get(pkg_identity));
locked_pkgs.and_then(|locked_pkgs| locked_pkgs.get(pkg_type_name));

for pkg_info in pkg_infos.iter() {
// Check if the candidate is a locked one.
Expand Down Expand Up @@ -361,14 +361,13 @@ pub fn get_pkg_info_from_candidates(
version: &str,
all_candidates: &HashMap<PkgTypeName, HashSet<PkgInfo>>,
) -> Result<PkgInfo> {
let pkg_type_enum = pkg_type.parse::<PkgType>()?;
let pkg_identity = PkgTypeName {
pkg_type: pkg_type_enum,
let pkg_type_name = PkgTypeName {
pkg_type: pkg_type.parse::<PkgType>()?,
name: pkg_name.to_string(),
};
let version_parsed = Version::parse(version)?;
let pkg_info = all_candidates
.get(&pkg_identity)
.get(&pkg_type_name)
.and_then(|set| set.iter().find(|pkg| pkg.version == version_parsed))
.ok_or_else(|| {
anyhow!(
Expand Down

0 comments on commit 14c94ff

Please sign in to comment.