Commit graph

12 commits

Author SHA1 Message Date
Till Wegmueller
f8ab1f94c1 fix: Resolve SHA1/SHA-256 hash mismatch in manifest lookups, complete search endpoints
fetch_manifest and the receiver were parsing legacy text manifests which
reference SHA1 hashes, while pkg5-imported repos store files under SHA-256.
Prefer the JSON manifest (.json) everywhere so payload lookups find the
correct files. Fixes archive creation, archive import, and local
FileBackend-to-FileBackend receive for pkg5-imported repositories.

Also completes the search REST API: v0 now returns 204 for empty results
per the pkg5 spec, and publisher-less routes (/search/0/, /search/1/) are
added for clients that omit the publisher prefix.
2026-04-09 22:06:48 +02:00
Till Wegmueller
6f5040978b fix: Deduplicate payload downloads to prevent parallel rename races
Multiple file actions in a manifest can reference the same payload hash.
When downloaded in parallel via rayon, multiple threads would write to
the same temp file path simultaneously, causing rename failures.

Now deduplicates payloads by digest before parallel download, then maps
results back to all file actions that reference each payload.
2026-03-15 21:14:35 +01:00
Till Wegmueller
bcea795848 fix: Store payloads under primary hash and fix digest detection
- Store compressed payloads under the primary (uncompressed) hash as
  the main key, matching IPS protocol where clients request files by
  the manifest's primary hash via /file/0/<hash>
- Create hardlink under compressed hash for internal lookups
- Detect SHA256 (64 chars) vs SHA1 (40 chars) from bare hex hash
  length in Digest::from_str instead of always defaulting to SHA1
- Remove digest verification for local file copies in FileBackend
  (files are compressed, hash is of uncompressed content)
- Simplify recv.rs payload fetch to use primary hash directly
  instead of trying multiple digest formats against the source
2026-03-15 20:58:44 +01:00
Till Wegmueller
a0fe229ba4 fix: Store payload files under both compressed and primary hash
Files were only stored under their compressed SHA256 hash, but pkg5
clients and the IPS protocol look up files by the manifest's primary
hash (typically SHA1/SHA256 uncompressed). Create a hardlink from the
primary hash path to the compressed hash file so both old and new
clients can find payloads via the server's /file/0/<hash> endpoint.
2026-03-15 20:44:43 +01:00
Till Wegmueller
0a28909e9e 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).
2026-03-15 20:39:50 +01:00
Till Wegmueller
750df8dcc7 fix: Resolve pkg6recv multithreaded download race conditions and file loss
- Use tempdir_in(repo_path) instead of system /tmp to keep temp files on
  the same filesystem, preventing cross-device rename failures
- Replace fs::copy with fs::rename for atomic file moves in transaction
  commit and signature payload storage
- Fix Digest construction to use correct SHA256 algorithm instead of
  defaulting to SHA1 for bare hex hashes
- Try compressed hash (additional_identifiers) as fallback when primary
  hash lookup fails during payload fetch
- Remove duplicate publisher resolution block in Transaction::commit()
- Add integration test for multi-file parallel package receive

Closes: https://codeberg.org/Toasterson/ips/issues/21
2026-03-15 19:32:24 +01:00
Till Wegmueller
ac9ab8c447
feat: Enhance signature payload handling and add test coverage
- Made `receive_one` public to allow external use.
- Improved signature payload fetching, storing, and fallback logic for `FileBackend` repositories.
- Added test case `test_receive_with_signature` to verify signature handling and repository storage.
- Extended manifest fields in transaction logic to support additional attributes (e.g., `users`, `groups`, `drivers`).
- Updated `RestBackend` to handle extended file path lookups for signature payloads.
2026-02-06 00:40:59 +01:00
Till Wegmueller
dfc24725b8
Add signature handling for manifests
- Implemented support for fetching, importing, and storing signature payloads during transaction creation.
- Added the `Signature` struct to represent signature-related action data.
- Updated `Manifest` to include and process `signatures` as part of its fields.
- Enabled signature file imports with proper path resolution in `pkg6repo`.
2026-02-05 22:26:53 +01:00
Till Wegmueller
e236f30f6e
Convert trait methods to use &self instead of &mut self, introduce Mutex for interior mutability, optimize HTTP client creation, and implement parallel payload processing using Rayon. 2026-02-05 15:57:56 +01:00
Till Wegmueller
4ab529f4c7
chore(format): format code 2026-01-25 23:17:49 +01:00
Till Wegmueller
e1ce390abd
Refactor code to simplify handling and remove unused functions
- Removed `add_package` function from `FileBackend`, consolidating package indexing logic.
- Allowed unused assignments using `#![allow(unused_assignments)]` where necessary.
- Addressed unused imports in integration tests.
- Simplified `Digest` error handling by removing unreachable branches for unknown algorithms.
2026-01-20 22:19:25 +01:00
Till Wegmueller
1c0619ca55
Add pkg6recv package for receiving IPS repositories.
- Introduced `pkg6recv` for downloading packages from IPS repositories with support for recursive dependency fetching.
- Implemented CLI commands with `clap` for source/destination setup, package selection, and publisher defaults.
- Added `ConsoleProgressReporter` for detailed receive progress visibility.
- Enhanced the `Manifest` parser to support JSON format alongside IPS text format.
- Updated `FileBackend` and `RestBackend` repositories to fetch manifests and payloads in new operations.
- Extended `Digest` utilities for payload integrity checks.
- Added tests to verify basic functionality and manifest format preservation.
2026-01-20 20:16:58 +01:00