Skip to content

Commit

Permalink
Fix bug if different versions are present for different architectures…
Browse files Browse the repository at this point in the history
… that are both outdated
  • Loading branch information
kpcyrd committed Oct 30, 2024
1 parent 78a898e commit 41d22eb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct CacheEntry {
pub info: PkgInfo,
}

fn is_compatible(debversion: &str, crateversion: &VersionReq) -> Result<bool, Error> {
fn parse_deb_version(debversion: &str) -> Result<Version> {
let mut debversion = debversion.replace('~', "-");
if let Some((version, _suffix)) = debversion.split_once('+') {
debversion = match version.matches('.').count() {
Expand All @@ -40,7 +40,11 @@ fn is_compatible(debversion: &str, crateversion: &VersionReq) -> Result<bool, Er
};
}
let debversion = Version::parse(&debversion)?;
Ok(debversion)
}

fn is_compatible(debversion: &str, crateversion: &VersionReq) -> Result<bool, Error> {
let debversion = parse_deb_version(debversion)?;
Ok(crateversion.matches(&debversion))
}

Expand Down Expand Up @@ -205,6 +209,15 @@ impl Connection {
} else if info.status == PkgStatus::NotFound {
info.version = debversion.to_string();
info.status = PkgStatus::Outdated;
} else if info.status == PkgStatus::Outdated {
if let (Ok(existing), Ok(ours)) = (
parse_deb_version(&info.version),
parse_deb_version(debversion),
) {
if existing < ours {
info.version = debversion.to_string();
}
}
}
}

Expand Down

0 comments on commit 41d22eb

Please sign in to comment.