From 96b7793710e7364934ad6179866e07ccf3cc634b Mon Sep 17 00:00:00 2001 From: Opposite34 <54463205+Opposite34@users.noreply.github.com> Date: Sun, 28 Dec 2025 10:14:10 +0900 Subject: [PATCH 1/4] cli: (wip), aim to fix #128. doesn't clean up previous package --- crates/soar-cli/src/apply.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/soar-cli/src/apply.rs b/crates/soar-cli/src/apply.rs index 1186b4ed..4ef3bbd7 100644 --- a/crates/soar-cli/src/apply.rs +++ b/crates/soar-cli/src/apply.rs @@ -136,21 +136,24 @@ async fn compute_diff( let is_already_installed = installed_packages.iter().any(|ip| ip.is_installed); + let existing_install = installed_packages.into_iter().next(); + let target = InstallTarget { + package: url_pkg.to_package(), + existing_install: existing_install.clone(), + with_pkg_id: url_pkg.pkg_type.is_some(), + pinned: true, + profile: pkg.profile.clone(), + portable: pkg.portable.as_ref().and_then(|p| p.path.clone()), + portable_home: pkg.portable.as_ref().and_then(|p| p.home.clone()), + portable_config: pkg.portable.as_ref().and_then(|p| p.config.clone()), + portable_share: pkg.portable.as_ref().and_then(|p| p.share.clone()), + portable_cache: pkg.portable.as_ref().and_then(|p| p.cache.clone()), + }; + if !is_already_installed { - let existing_install = installed_packages.into_iter().next(); - let target = InstallTarget { - package: url_pkg.to_package(), - existing_install, - with_pkg_id: url_pkg.pkg_type.is_some(), - pinned: true, - profile: pkg.profile.clone(), - portable: pkg.portable.as_ref().and_then(|p| p.path.clone()), - portable_home: pkg.portable.as_ref().and_then(|p| p.home.clone()), - portable_config: pkg.portable.as_ref().and_then(|p| p.config.clone()), - portable_share: pkg.portable.as_ref().and_then(|p| p.share.clone()), - portable_cache: pkg.portable.as_ref().and_then(|p| p.cache.clone()), - }; diff.to_install.push((pkg.clone(), target)); + } else if pkg.version != Some(existing_install.unwrap().version) { + diff.to_update.push((pkg.clone(), target)); } else { diff.in_sync.push(format!("{} (local)", pkg.name)); } From d3ecc506ab14c16e264ae4e03ea996729ebd8e57 Mon Sep 17 00:00:00 2001 From: Opposite34 <54463205+Opposite34@users.noreply.github.com> Date: Sun, 28 Dec 2025 14:07:09 +0900 Subject: [PATCH 2/4] cli: partial fix to #128 (works when using prune) --- crates/soar-cli/src/apply.rs | 14 ++++++++------ crates/soar-cli/src/update.rs | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/soar-cli/src/apply.rs b/crates/soar-cli/src/apply.rs index 4ef3bbd7..6d453f67 100644 --- a/crates/soar-cli/src/apply.rs +++ b/crates/soar-cli/src/apply.rs @@ -23,6 +23,7 @@ use tracing::{error, info, warn}; use crate::{ install::{create_install_context, perform_installation}, + update::perform_update, state::AppState, utils::{display_settings, icon_or, Colored, Icons}, }; @@ -99,11 +100,11 @@ async fn compute_diff( let diesel_db = state.diesel_core_db()?.clone(); let mut diff = ApplyDiff::default(); - let mut declared_keys: HashSet<(String, Option, Option)> = HashSet::new(); + let mut declared_keys: HashSet<(String, Option, Option, Option)> = HashSet::new(); for pkg in resolved { // Track declared package - declared_keys.insert((pkg.name.clone(), pkg.pkg_id.clone(), pkg.repo.clone())); + declared_keys.insert((pkg.name.clone(), pkg.pkg_id.clone(), pkg.repo.clone(), pkg.version.clone())); // Handle URL packages if let Some(ref url) = pkg.url { @@ -141,7 +142,7 @@ async fn compute_diff( package: url_pkg.to_package(), existing_install: existing_install.clone(), with_pkg_id: url_pkg.pkg_type.is_some(), - pinned: true, + pinned: false, profile: pkg.profile.clone(), portable: pkg.portable.as_ref().and_then(|p| p.path.clone()), portable_home: pkg.portable.as_ref().and_then(|p| p.home.clone()), @@ -275,11 +276,12 @@ async fn compute_diff( .collect(); for installed in all_installed { - let is_declared = declared_keys.iter().any(|(name, pkg_id, repo)| { + let is_declared = declared_keys.iter().any(|(name, pkg_id, repo, version)| { let name_matches = *name == installed.pkg_name; let pkg_id_matches = pkg_id.as_ref().map_or(true, |id| *id == installed.pkg_id); let repo_matches = repo.as_ref().map_or(true, |r| *r == installed.repo_name); - name_matches && pkg_id_matches && repo_matches + let version_matches = version.as_ref().map_or(true, |v| *v == installed.version); + name_matches && pkg_id_matches && repo_matches && version_matches }); if !is_declared { @@ -510,7 +512,7 @@ async fn execute_apply(state: &AppState, diff: ApplyDiff, no_verify: bool) -> So no_verify, ); - perform_installation(ctx.clone(), targets, diesel_db.clone(), true).await?; + perform_update(ctx.clone(), targets, diesel_db.clone(), true).await?; updated_count = ctx.installed_count.load(Ordering::Relaxed) as usize; failed_count += ctx.failed.load(Ordering::Relaxed) as usize; } diff --git a/crates/soar-cli/src/update.rs b/crates/soar-cli/src/update.rs index 6890c290..35a2176e 100644 --- a/crates/soar-cli/src/update.rs +++ b/crates/soar-cli/src/update.rs @@ -216,7 +216,7 @@ pub async fn update_packages( Ok(()) } -async fn perform_update( +pub async fn perform_update( ctx: InstallContext, targets: Vec, diesel_db: DieselDatabase, From 9671fec6c6e5d0edeabe27d5d2a8a171991dc2d7 Mon Sep 17 00:00:00 2001 From: Opposite34 <54463205+Opposite34@users.noreply.github.com> Date: Sun, 28 Dec 2025 14:55:07 +0900 Subject: [PATCH 3/4] cli: fully fix #128, reverted prune related version checks and unpin/unkeep url packages --- crates/soar-cli/src/apply.rs | 13 ++++++------- crates/soar-cli/src/install.rs | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/soar-cli/src/apply.rs b/crates/soar-cli/src/apply.rs index 6d453f67..89c56bde 100644 --- a/crates/soar-cli/src/apply.rs +++ b/crates/soar-cli/src/apply.rs @@ -100,11 +100,11 @@ async fn compute_diff( let diesel_db = state.diesel_core_db()?.clone(); let mut diff = ApplyDiff::default(); - let mut declared_keys: HashSet<(String, Option, Option, Option)> = HashSet::new(); + let mut declared_keys: HashSet<(String, Option, Option)> = HashSet::new(); for pkg in resolved { // Track declared package - declared_keys.insert((pkg.name.clone(), pkg.pkg_id.clone(), pkg.repo.clone(), pkg.version.clone())); + declared_keys.insert((pkg.name.clone(), pkg.pkg_id.clone(), pkg.repo.clone())); // Handle URL packages if let Some(ref url) = pkg.url { @@ -153,7 +153,7 @@ async fn compute_diff( if !is_already_installed { diff.to_install.push((pkg.clone(), target)); - } else if pkg.version != Some(existing_install.unwrap().version) { + } else if url_pkg.version != existing_install.unwrap().version { diff.to_update.push((pkg.clone(), target)); } else { diff.in_sync.push(format!("{} (local)", pkg.name)); @@ -276,12 +276,11 @@ async fn compute_diff( .collect(); for installed in all_installed { - let is_declared = declared_keys.iter().any(|(name, pkg_id, repo, version)| { + let is_declared = declared_keys.iter().any(|(name, pkg_id, repo)| { let name_matches = *name == installed.pkg_name; let pkg_id_matches = pkg_id.as_ref().map_or(true, |id| *id == installed.pkg_id); let repo_matches = repo.as_ref().map_or(true, |r| *r == installed.repo_name); - let version_matches = version.as_ref().map_or(true, |v| *v == installed.version); - name_matches && pkg_id_matches && repo_matches && version_matches + name_matches && pkg_id_matches && repo_matches }); if !is_declared { @@ -512,7 +511,7 @@ async fn execute_apply(state: &AppState, diff: ApplyDiff, no_verify: bool) -> So no_verify, ); - perform_update(ctx.clone(), targets, diesel_db.clone(), true).await?; + perform_update(ctx.clone(), targets, diesel_db.clone(), false).await?; updated_count = ctx.installed_count.load(Ordering::Relaxed) as usize; failed_count += ctx.failed.load(Ordering::Relaxed) as usize; } diff --git a/crates/soar-cli/src/install.rs b/crates/soar-cli/src/install.rs index 7899cf62..ce1fdc77 100644 --- a/crates/soar-cli/src/install.rs +++ b/crates/soar-cli/src/install.rs @@ -266,7 +266,7 @@ fn resolve_packages( package: url_pkg.to_package(), existing_install, with_pkg_id: url_pkg.pkg_type.is_some(), - pinned: true, // URL packages are always pinned + pinned: false, profile: None, ..Default::default() }); From 3adb99d5986a8adcc77a6907431a1a06655b6a59 Mon Sep 17 00:00:00 2001 From: Rabindra Dhakal Date: Sun, 28 Dec 2025 11:45:19 +0545 Subject: [PATCH 4/4] fmt --- crates/soar-cli/src/apply.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/soar-cli/src/apply.rs b/crates/soar-cli/src/apply.rs index 89c56bde..bd308f3e 100644 --- a/crates/soar-cli/src/apply.rs +++ b/crates/soar-cli/src/apply.rs @@ -23,8 +23,8 @@ use tracing::{error, info, warn}; use crate::{ install::{create_install_context, perform_installation}, - update::perform_update, state::AppState, + update::perform_update, utils::{display_settings, icon_or, Colored, Icons}, };