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 and refactor cache_info_with_warnings #1290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 10 additions & 9 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,22 @@ pub async fn cache_info_with_warnings<'a, S: AsRef<str> + Send + Sync>(
let mut missing = Vec::new();
let mut ood = Vec::new();
let mut orphaned = Vec::new();
let mut aur_pkgs = raur.cache_info(cache, pkgs).await?;

let mut aur_pkgs = raur.cache_info(cache, pkgs).await?;
aur_pkgs.retain(|pkg1| pkgs.iter().any(|pkg2| pkg1.name == pkg2.as_ref()));

let should_warn =
|pkg: &str| !no_warn.is_match(pkg) && !ignore.iter().any(|ignored| ignored == pkg);

for pkg in pkgs {
if !no_warn.is_match(pkg.as_ref())
&& !ignore.iter().any(|p| p == pkg.as_ref())
&& !cache.contains(pkg.as_ref())
{
missing.push(pkg.as_ref())
let pkg_name = pkg.as_ref();
if should_warn(pkg_name) && !cache.contains(pkg_name) {
missing.push(pkg_name);
}
}

for pkg in &aur_pkgs {
if no_warn.is_match(&pkg.name) && !ignore.iter().any(|p| p.as_str() == pkg.name) {
if should_warn(&pkg.name) {
if pkg.out_of_date.is_some() {
ood.push(cache.get(pkg.name.as_str()).unwrap().name.as_str());
romanstingler marked this conversation as resolved.
Show resolved Hide resolved
}
Expand All @@ -163,14 +164,14 @@ pub async fn cache_info_with_warnings<'a, S: AsRef<str> + Send + Sync>(
}
}

let ret = Warnings {
let warnings = Warnings {
pkgs: aur_pkgs,
missing,
ood,
orphans: orphaned,
};

Ok(ret)
Ok(warnings)
}

pub async fn getpkgbuilds(config: &mut Config) -> Result<i32> {
Expand Down
Loading