Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions crates/soar-cli/src/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use tracing::{error, info, warn};
use crate::{
install::{create_install_context, perform_installation},
state::AppState,
update::perform_update,
utils::{display_settings, icon_or, Colored, Icons},
};

Expand Down Expand Up @@ -136,21 +137,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: 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()),
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 url_pkg.version != existing_install.unwrap().version {
diff.to_update.push((pkg.clone(), target));
} else {
diff.in_sync.push(format!("{} (local)", pkg.name));
}
Expand Down Expand Up @@ -507,7 +511,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(), false).await?;
updated_count = ctx.installed_count.load(Ordering::Relaxed) as usize;
failed_count += ctx.failed.load(Ordering::Relaxed) as usize;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/soar-cli/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});
Expand Down
2 changes: 1 addition & 1 deletion crates/soar-cli/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub async fn update_packages(
Ok(())
}

async fn perform_update(
pub async fn perform_update(
ctx: InstallContext,
targets: Vec<InstallTarget>,
diesel_db: DieselDatabase,
Expand Down