Skip to content

Commit

Permalink
add missing method to trait and core
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed Dec 15, 2024
1 parent 82f12c6 commit 2b10d63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/backends/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ pub trait Backend {
fn clean_cache(config: &Config) -> Result<()>;

fn version(config: &Config) -> Result<String>;

fn missing(managed: Self::InstallOptions, installed: Option<Self::QueryInfo>) -> Option<Self::InstallOptions>;
}
12 changes: 8 additions & 4 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,19 @@ fn unmanaged(managed: &InstallOptions, config: &Config) -> Result<PackageIds> {
.map(|x| x.to_package_ids().difference(&managed.to_package_ids()))
}
fn missing(managed: &InstallOptions, config: &Config) -> Result<InstallOptions> {
let installed = QueryInfos::query_installed_packages(config)?.to_package_ids();
let installed = QueryInfos::query_installed_packages(config)?;

let mut missing = managed.clone();
let mut missing = InstallOptions::default();

macro_rules! x {
($(($upper_backend:ident, $lower_backend:ident)),*) => {
$(
for package in installed.$lower_backend {
missing.$lower_backend.remove(&package);
for (package_id, managed_install_options) in managed.$lower_backend.iter() {
if let Some(missing_install_options) =
$upper_backend::missing(managed_install_options.clone(), installed.$lower_backend.get(package_id).cloned())
{
missing.$lower_backend.insert(package_id.clone(), missing_install_options);
}
}
)*
};
Expand Down

0 comments on commit 2b10d63

Please sign in to comment.