Skip to content

Commit

Permalink
fix(install): fix package case handling & replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
QaidVoid committed Nov 8, 2024
1 parent 4bbe1f3 commit 5af3cfc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/package/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,12 @@ impl Installer {
let symlink_path = &BIN_PATH.join(&package.pkg_name);
if symlink_path.exists() {
if let Ok(link) = symlink_path.read_link() {
if *install_path == link {
return Ok(())
}
if let Ok(parent) = link.strip_prefix(&*PACKAGES_PATH) {
let package_name = &parent.parent().unwrap().to_string_lossy()[9..];
let package_path = parent.parent().unwrap().to_string_lossy();
let package_name = &package_path[..8];

if package_name == package.full_name('-') {
fs::remove_dir_all(link.parent().unwrap()).await?;
Expand Down
2 changes: 1 addition & 1 deletion src/registry/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl MetadataFetcher {
.map(|(key, packages)| {
let package_map: HashMap<String, Vec<Package>> =
packages.iter().fold(HashMap::new(), |mut acc, package| {
acc.entry(package.pkg.clone()).or_default().push(Package {
acc.entry(package.pkg.to_lowercase().clone()).or_default().push(Package {
family: package
.download_url
.split('/')
Expand Down
2 changes: 1 addition & 1 deletion src/registry/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl PackageStorage {
.flat_map(|(collection_key, map)| {
map.get(pkg_name).into_iter().flat_map(|pkgs| {
pkgs.iter().filter_map(|pkg| {
if pkg.pkg == pkg_name
if pkg.pkg.to_lowercase() == pkg_name
&& (query.family.is_none()
|| pkg.family.as_ref() == query.family.as_ref())
{
Expand Down

0 comments on commit 5af3cfc

Please sign in to comment.