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 bug if different versions are present for different architectures… #47

Merged
merged 1 commit into from
Oct 31, 2024
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
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
Loading