From 0a28909e9e46eec03085cb0e9e4b4c6625aaf040 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sun, 15 Mar 2026 20:39:50 +0100 Subject: [PATCH] fix: Try raw hash before formatted digest in payload fetch fallback The previous digest fallback used Display format (source:algorithm:hash) which caused REST servers to look up files by SHA256 compressed hash instead of the expected SHA1 primary hash. Now tries raw hash first (compatible with pkg5 REST servers), then formatted variants with algorithm info (compatible with local FileBackend storage). --- libips/src/recv.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libips/src/recv.rs b/libips/src/recv.rs index b8b2d7a..ec12b3e 100644 --- a/libips/src/recv.rs +++ b/libips/src/recv.rs @@ -228,12 +228,22 @@ impl<'a, S: ReadableRepository + Sync> PackageReceiver<'a, S> { .map(|file| { let payload = file.payload.as_ref().unwrap(); - // Collect all candidate digests: primary first, then additional (compressed hash) - // Use Display format (source:algorithm:hash) so fetch_payload parses correctly - let mut digests = vec![payload.primary_identifier.to_string()]; + // Collect candidate digests to try: raw primary hash first (works with + // REST servers that use SHA1), then formatted digests with algorithm info + // (works with FileBackend that may store under compressed hash) + let mut digests = vec![payload.primary_identifier.hash.clone()]; + // Add formatted primary with algorithm info as second attempt + let formatted_primary = payload.primary_identifier.to_string(); + if formatted_primary != payload.primary_identifier.hash { + digests.push(formatted_primary); + } for additional in &payload.additional_identifiers { if !additional.hash.is_empty() { - digests.push(additional.to_string()); + digests.push(additional.hash.clone()); + let formatted = additional.to_string(); + if formatted != additional.hash { + digests.push(formatted); + } } }