Skip to content

Commit

Permalink
Fix: update and reinstall dependencies when requested
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Oct 21, 2024
1 parent 9e7f58d commit e3001ab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fetchy"
version = "0.13.2"
version = "0.13.3"
edition = "2021"
description = "Quick packages installer"
license = "Apache-2.0"
Expand Down
65 changes: 30 additions & 35 deletions src/install/phases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,49 +117,44 @@ pub async fn determine_install_phases<'a, 'b>(

// Fetch informations about packages that require it
for (pkg, asset_infos) in fetch_resolved_pkg_infos(&missing).await? {
match (db.installed.get(&pkg.manifest.name), pkg.is_dep) {
// Missing (= not yet installed) dependency
(None, true) => {
phases.to_install.missing_deps.push((pkg, asset_infos));
}

// Already installed dependency
(Some(_), true) => {
phases.untouched.already_installed_deps.push(pkg);
}

// Missing (= not yet installed) non-dependency package
(None, false) => {
phases.to_install.missing_pkgs.push((pkg, asset_infos));
match db.installed.get(&pkg.manifest.name) {
None => {
if pkg.is_dep {
phases.to_install.missing_deps.push((pkg, asset_infos));
} else {
phases.to_install.missing_pkgs.push((pkg, asset_infos));
}
}

// Already installed non-dependency package
(Some(already_installed), false) => match installed_pkgs_handling {
InstalledPackagesHandling::Ignore => {
unreachable!()
}
Some(already_installed) => {
match installed_pkgs_handling {
InstalledPackagesHandling::Ignore => {
assert!(!pkg.is_dep);
}

InstalledPackagesHandling::CheckUpdates => {
// Show if there's an update and that's all
if asset_infos.version == already_installed.version {
phases.untouched.no_update_needed.push(pkg);
} else {
phases.untouched.update_available.push((pkg, asset_infos));
InstalledPackagesHandling::CheckUpdates => {
// Show if there's an update and that's all
if asset_infos.version == already_installed.version {
phases.untouched.no_update_needed.push(pkg);
} else {
phases.untouched.update_available.push((pkg, asset_infos));
}
}
}

InstalledPackagesHandling::Update => {
if asset_infos.version == already_installed.version {
phases.untouched.no_update_needed.push(pkg);
} else {
phases.to_install.needs_updating.push((pkg, asset_infos));
InstalledPackagesHandling::Update => {
// Show if there's an update and that's all
if asset_infos.version == already_installed.version {
phases.untouched.no_update_needed.push(pkg);
} else {
phases.untouched.update_available.push((pkg, asset_infos));
}
}
}

InstalledPackagesHandling::Reinstall => {
phases.to_install.reinstall.push((pkg, asset_infos));
InstalledPackagesHandling::Reinstall => {
phases.to_install.reinstall.push((pkg, asset_infos));
}
}
},
}
}
}

Expand Down

0 comments on commit e3001ab

Please sign in to comment.