install: restart a download once on 416 (#28) #123
No reviewers
Labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
schaefera/utStudyBIble!123
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/install-416-restart"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #28
What
A resumed download whose part file is past the end of the server's file (the file shrank since the part was written) gets a 416 Range Not Satisfiable. Until now that 416 stopped the install. Now the first 416 per transfer discards the part and state, emits
Event::Restart("range not satisfiable") and downloads again from byte 0. A second 416 still stops withHttp(416), so a server that always answers 416 can't loop. The test server learns to answer 416, and to drop its validators.Blast radius
Tier: trunk
Trunk paths touched:
sword/src/install/http.rs,sword/src/install/http/tests.rs,sword/src/install/testserver.rsTesting tier: standard
Gate / rollback: revert this merge. There is no flag: before this change, the same case already ended the install with an error, so a revert only brings that error back. Memory and start-up are unaffected: one bool per transfer, and nothing new runs at start.
Proof
http.rsand this branch's tests and test server, both new tests FAIL ("0 passed; 2 failed"; panics at tests.rs:357 and 374). On this branch they pass ("2 passed").a_file_that_shrank_below_the_part_restarts_on_416a_server_that_always_answers_416_fails_after_one_restartcargo make: fmt, clippy, tests with coverage, release check, cargo-deny and cargo-audit all pass.98c2484: green.tasks/was left empty.Review
Reviewer: a fresh-context review at high on
2bab224(review 326) found no high or medium issues, and 2 low ones. Both are fixed in98c2484and answered in comment 2458:There was no re-review, because both findings were low.
Review-Confidence: 75/100. The audit took 20 off because no reviewer saw the test server's If-Range change in
98c2484(it is code, though the auditor read it and found it correct), and 5 off for the doc fix made after the review. It found no missed defect.Confidence by part
http.rs: high. It fails on the base and passes on the branch, and the phone run covers the real server.🤖 Generated with Claude Code
Fresh-context review. Level: high. Blast radius: trunk.
Reviewed commit:
2bab224a5cRange: origin/main...HEAD
Files reviewed: sword/src/install/http.rs, sword/src/install/http/tests.rs, sword/src/install/testserver.rs (plus context: sword/src/install.rs Event::Restart, docs mentions of Range/If-Range)
No high or medium defects. The 416 handling is correct: the restart discards part and state, the
runloop then re-requests from byte 0 with no validator, therestarted_416flag bounds it to one restart so a persistent 416 ends asError::Http(416), andhttp_status_as_error(false)means the 416 actually reaches the match. The?onrestart()converts io errors toStep::Fatalas for the other restart sites.Findings outside the diff:
Inline: one low finding in the test server.
@ -166,3 +178,4 @@if req.if_none_match.as_deref() == Some(etag) {return (format!("HTTP/1.1 304 Not Modified\r\nETag: {etag}\r\n"), vec![], None);}// As real servers do: a Range starting at or past the end is a 416.low · The 416 check runs before the If-Range check. A real server evaluates If-Range first: with a stale validator it ignores Range and answers 200 with the whole file, even when the Range start is past the end. A future test that combines a mismatched If-Range with a part longer than the new file would get a 416 here where production gets a 200, so it would exercise the wrong path. Move the 416 after the If-Range validation, i.e. apply it only when
req.if_range.as_ref().is_none_or(if_range_ok)holds.Round 1 response (fixed in
98c2484):cargo make passed.
Phone (Plinius, arm64 click of
98c2484, mobile data): a real 416 from CrossWire, recovered.fix/install-416-restart@98c2484f5. The window loaded after 317 ms and restored BSB Prov 7.kill -9at 732107 bytes. That lefttasks/LXX.zip.partandLXX.zip.state(CrossWire's ETag"67dfd2-630ff1fa4462f").totalto 7000000 and padded the part to 6900000 bytes, past the real end. The resume request it makes,Range: bytes=6900000-with thatIf-Range, gets a 416 from crosswire.org (checked with curl).install LXX queued, thendownloading, theninstalled29 s later.tasks/was left empty.ot.bzz8383969,ot.bzv329410, …), and the app checked the zip's CRCs when it unpacked it. So the padding was thrown away, not installed.Found on the way, not caused by this PR: LXX's versification isn't supported, so the installed module never shows in the Bible chooser. Filed as #124.
The PR build is left installed on the phone.
🤖 Generated with Claude Code
WIP: install: restart a download once on HTTP 416 (#28)to install: restart a download once on 416 (#28)Gate approval on
98c2484. Review 326 had no high or medium findings; its two lows are fixed in98c2484, the only commit after that review. I readgit diff 2bab224..98c2484:CI is green on head: all 7 statuses succeeded. Proof shows the new tests failing on main and passing on the branch,
cargo makepassing, and the phone run (comment 2463). The testing tier is standard, so there is no elevated, maximum or AI gate left unrun.