Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(oma-pm): do not push repetition suggest pkgs #351

Merged
merged 2 commits into from
Feb 24, 2025
Merged
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
28 changes: 15 additions & 13 deletions oma-pm/src/apt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@ impl OmaApt {
let mut autoremovable = (0, 0);
let changes = self.cache.get_changes(sort == SummarySort::Names);

let mut suggest = vec![];
let mut recommend = vec![];
let mut suggest = HashSet::with_hasher(ahash::RandomState::new());
let mut recommend = HashSet::with_hasher(ahash::RandomState::new());

for pkg in changes {
if pkg.marked_new_install() {
Expand Down Expand Up @@ -1092,8 +1092,8 @@ impl OmaApt {
disk_size_delta,
total_download_size,
autoremovable,
suggest,
recommend,
suggest: suggest.into_iter().collect(),
recommend: recommend.into_iter().collect(),
})
}

Expand Down Expand Up @@ -1186,8 +1186,8 @@ fn get_package_url(cand: &Version<'_>) -> Vec<PackageUrl> {

fn collect_recommends_and_suggests(
cache: &Cache,
suggest: &mut Vec<(String, String)>,
recommend: &mut Vec<(String, String)>,
suggest: &mut HashSet<(String, String)>,
recommend: &mut HashSet<(String, String)>,
version: &Version<'_>,
) {
if let Some(s) = version.depends_map().get(&oma_apt::DepType::Suggests) {
Expand All @@ -1201,7 +1201,7 @@ fn collect_recommends_and_suggests(

fn collect_suggest(
cache: &Cache,
suggest: &mut Vec<(String, String)>,
suggest: &mut HashSet<(String, String)>,
packages: &[Dependency<'_>],
) {
for deps in OmaDependency::map_deps(packages).inner() {
Expand All @@ -1223,7 +1223,7 @@ fn collect_suggest(
continue;
};

suggest.push((pkg.fullname(true), desc));
suggest.insert((pkg.fullname(true), desc));
}
} else {
let pkgs = deps
Expand All @@ -1232,9 +1232,11 @@ fn collect_suggest(
.flat_map(|pkg| cache.get(pkg))
.collect::<Vec<_>>();

let all_not_marked_install = pkgs.iter().all(|pkg| !pkg.marked_install());
let all_not_marked_install_and_is_installed = pkgs
.iter()
.all(|pkg| !pkg.marked_install() && !pkg.is_installed());

if all_not_marked_install {
if all_not_marked_install_and_is_installed {
for pkg in pkgs {
let Some(cand) = pkg.candidate() else {
continue;
Expand All @@ -1244,7 +1246,7 @@ fn collect_suggest(
continue;
};

suggest.push((pkg.fullname(true), desc));
suggest.insert((pkg.fullname(true), desc));
}
}
}
Expand Down Expand Up @@ -1279,8 +1281,8 @@ fn pkg_delta(
new_pkg: &Package,
op: InstallOperation,
cache: &Cache,
suggest: &mut Vec<(String, String)>,
recommend: &mut Vec<(String, String)>,
suggest: &mut HashSet<(String, String)>,
recommend: &mut HashSet<(String, String)>,
) -> OmaAptResult<InstallEntry> {
let cand = new_pkg
.candidate()
Expand Down
Loading