From c14ea99dc28f02dc139b8a81b42f29b4e0422491 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Fri, 12 Dec 2025 18:22:29 +0100 Subject: [PATCH] pull: use the most recent pocket first on 'find' --- src/package_info.rs | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/package_info.rs b/src/package_info.rs index ee464d3..371a0f1 100644 --- a/src/package_info.rs +++ b/src/package_info.rs @@ -143,6 +143,14 @@ pub struct PackageInfo { pub archive_url: String, } +fn get_dist_pockets(dist: &str) -> Vec<&'static str> { + match dist { + "ubuntu" => vec!["proposed", "updates", ""], + "debian" => vec!["proposed-updates", "updates", ""], + _ => vec![""], + } +} + fn get_sources_url(base_url: &str, series: &str, pocket: &str, component: &str) -> String { let pocket_full = if pocket.is_empty() { String::new() @@ -362,20 +370,31 @@ pub async fn find_package( cb("", &format!("Checking {}...", series), i, series_list.len()); } - match get(package_name, series, pocket, version).await { - Ok(info) => { - if i > 0 { - warn!( - "Package '{}' not found in development release. Found in {}/{}.", - package_name, dist, series - ); - } else { - debug!("Found package '{}' in {}/{}", package_name, dist, series); + let pockets = if pocket.is_empty() { + get_dist_pockets(dist) + } else { + vec![pocket] + }; + + for p in pockets { + match get(package_name, series, p, version).await { + Ok(info) => { + if i > 0 { + warn!( + "Package '{}' not found in development release. Found in {}/{}-{}.", + package_name, dist, series, p + ); + } else { + debug!( + "Found package '{}' in {}/{}-{}", + package_name, dist, series, p + ); + } + return Ok(info); + } + Err(_e) => { + continue; } - return Ok(info); - } - Err(_e) => { - continue; } } }