diff --git a/crates/rattler/src/install/clobber_registry.rs b/crates/rattler/src/install/clobber_registry.rs index f3e3789ff..dda17dfa1 100644 --- a/crates/rattler/src/install/clobber_registry.rs +++ b/crates/rattler/src/install/clobber_registry.rs @@ -65,13 +65,19 @@ impl ClobberRegistry { .package_names .iter() .position(|n| n == originating_package) - .unwrap(); + .expect("package not found even though it was just added"); let path = *path; registry .clobbers .entry(path.clone()) - .or_insert_with(|| vec![*registry.paths_registry.get(path).unwrap()]) + .or_insert_with(|| { + if let Some(other_idx) = registry.paths_registry.get(path) { + vec![*other_idx] + } else { + Vec::new() + } + }) .push(idx); } @@ -97,21 +103,16 @@ impl ClobberRegistry { /// will "unclobber" the files after all packages have been installed. pub fn register_paths( &mut self, - name: &str, + name: &PackageName, paths_json: &PathsJson, ) -> HashMap { let mut clobber_paths = HashMap::new(); // check if we have the package name already registered - let name_idx = if let Some(idx) = self - .package_names - .iter() - .position(|n| n.as_normalized() == name) - { + let name_idx = if let Some(idx) = self.package_names.iter().position(|n| n == name) { idx } else { - self.package_names - .push(PackageName::try_from(name).unwrap()); + self.package_names.push(name.clone()); self.package_names.len() - 1 }; diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 900fc8abf..f3009c3bf 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -270,7 +270,7 @@ pub async fn link_package( let clobber_paths = Arc::new( driver .clobber_registry() - .register_paths(index_json.name.as_normalized(), &paths_json), + .register_paths(&index_json.name, &paths_json), ); // Start linking all package files in parallel