mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 21:30:41 +00:00
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).
This commit is contained in:
parent
d5ed328ab2
commit
0a28909e9e
1 changed files with 14 additions and 4 deletions
|
|
@ -228,12 +228,22 @@ impl<'a, S: ReadableRepository + Sync> PackageReceiver<'a, S> {
|
||||||
.map(|file| {
|
.map(|file| {
|
||||||
let payload = file.payload.as_ref().unwrap();
|
let payload = file.payload.as_ref().unwrap();
|
||||||
|
|
||||||
// Collect all candidate digests: primary first, then additional (compressed hash)
|
// Collect candidate digests to try: raw primary hash first (works with
|
||||||
// Use Display format (source:algorithm:hash) so fetch_payload parses correctly
|
// REST servers that use SHA1), then formatted digests with algorithm info
|
||||||
let mut digests = vec![payload.primary_identifier.to_string()];
|
// (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 {
|
for additional in &payload.additional_identifiers {
|
||||||
if !additional.hash.is_empty() {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue