feat(amuleapi): add POST /shared/{hash}/verify (Verify Local Data) - #528
Merged
got3nks merged 1 commit intoJul 20, 2026
Merged
Conversation
Exposes the Verify Local Data action over the REST API, reusing the EC_OP_VERIFY_LOCAL_DATA opcode added for the desktop clients. amuled re-hashes the file's on-disk data against its stored MD4 (and AICH, where a hashset exists) and reports any blocks that no longer match. The endpoint answers 202: amuled queues the hashing task and replies immediately, so the response only confirms the re-hash was scheduled. The verdict is emitted as an amule log line when the task finishes, which clients already read back through /logs/amule or the log SSE channel; that reporting path is documented rather than reinvented. Incomplete partfiles are rejected with 409 partfile_unsupported. The hashing task skips partfiles outright, so accepting one would promise a report that never arrives. The guard uses the same "genuinely incomplete" test as the `path` field, so a download that has finished but is still listed remains a valid target. Adds a curl smoke covering the accept path, the auth and method gates, unknown-hash 404 and the partfile 409, plus reference documentation.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exposes the Verify Local Data action over the REST API, following #491 which added it for the desktop clients. Reuses the
EC_OP_VERIFY_LOCAL_DATAopcode as-is — no core changes.POST /api/v0/shared/{hash}/verify(ADMIN) →202 {"ok": true}Up front: Verify Local Data has no mechanism to return its result to UI or EC clients.
CVerifyLocalDataTaskhas noOnExit(), emits no notification, raises no EC event, and changes no observable file state. It collectsm_corruptedMD4/m_corruptedAICHand nothing consumes them beyond formatting them into a single log line inPrintReport(). That limitation is the same for the monolithic GUI and amulegui as it is here — it isn't something this PR introduces or works around.So this endpoint can only honestly answer
202(the re-hash was scheduled) and point clients at the log. amuled queues the task and replies immediately; a large file may take minutes. The verdict then appears as:Verify Local Data (MD4 & AICH): Result OK for <path>Verify Local Data (MD4 & AICH): ERRORS FOUND! <path> Failed blocks: MD4: 3,7 …which clients read back through
/logs/amuleor thelogSSE channel. The reference documents exactly that, and flags it for what it is: the lines are gettext-translated and carry no correlation id tying them to a request, so they are human-readable output, not a machine-parseable contract. A structured result needs a core change (task notification → EC event → typed SSE event); better as a follow-up than a parallel path bolted onto this endpoint.Partfile guard. Incomplete partfiles are rejected with
409 partfile_unsupported— the hashing task skips partfiles outright, so accepting one would promise a report that never arrives. The guard reuses the same "genuinely incomplete" test as thepathfield, so a download that has finished but is still listed under/downloadsremains a valid target.Verification. Ran live against a real amuled; all 11 assertions pass, including the 409 guard (the node had an actual partfile, so that path was genuinely exercised rather than skipped):
Reporting confirmed end to end as well — after the 202 the daemon logged
Verify Local Data (MD4 & AICH): Result OK for …, readable back throughGET /api/v0/logs/amule.clang-format (v18, whole-file) and the clang-tidy Tier-1 + Tier-2 diff checks are both clean.