mycf_711 (Win11 26200, 0.1.2364 -> 0.1.2404): the first try failed at the
trial start with "fork/exec ...\magpie.exe.new: The process cannot access
the file because it is being used by another process", and every try
after it failed at once with 416. Both confirmed on xiaomi-gpu with the
old code and a real handle held on the download.
Cause: something (often an antivirus) holds the staged magpie.exe.new.
CreateProcess fails with a sharing violation and that was reported as a
BlockedError (a policy block, which stops the clock checks). download()
dropped os.Remove's error, so the held, complete file stayed, and fetch
resumed it with "Range: bytes=<size>-", which no host can satisfy.
Changes in internal/update:
- download clears the earlier file through clearFile; a held file gives a
clear error ("another program has it open...") instead of being ignored,
and every other Remove error is returned, not dropped.
- fetch: a leftover that is already whole and matches the hash is used with
no request; one that is whole but of other bytes starts over; a 416 starts
over from zero once.
- binaryStage takes a fresh name (magpie.exe.new-*) when the usual one is
held, and stagedFiles/RemoveStaleNew find and clear those too.
- the trial start waits while the download is held (waitHeld, as the aside
moves do); still held after the wait is an ordinary error that keeps the
download, not a BlockedError.
These run on macOS and Linux too (the held case can't happen there, the 416
and whole-leftover cases can).
Run at 003e55115 (on origin/main 7428f3229):
- mote: gofmt -l clean; go vet ./... for darwin, linux and windows; builds;
go test -tags nogui -count=1 -timeout 45m ./...: every package ok except
internal/gui, red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestColdTurnsTaken (#4510), both filed and in files this change doesn't
touch.
- xiaomi-gpu (win-run go test ./internal/update/...): 88 PASS, -count=3 of
the new tests ok; TestPackagedByDpkg red, the same on main (#4603: the
fixture name magpie:amd64.list is an NTFS stream).
- xiaomi-gpu internal/gui update tests: TestUpdateThatWontStart red, the
same on main (#4115).
- wsl-run (magpie-desktop) go test -tags nogui ./internal/update/...: ok.
Rebased on origin/main e40675cc1 (9 commits, none in internal/update) and
rerun there: mote vet (darwin, windows) and go test ./internal/update/... ok;
xiaomi-gpu the same, red only on TestPackagedByDpkg (#4603).
Broken by hand: origin/main's update.go with only the removeFile shim added
(scratchpad oldcode copy). mote: 5 red (WholeFileAsksNoRangePastTheEnd,
WholeFileOfOtherBytesStartsOver, 416StartsOverOnce, SaysAHeldLeftover,
StageStepsRoundAHeldLeftover). Windows: 8 red, those 5 plus
StageStepsRoundAFileHeldOpen ("416 ... asked [bytes=19-]") and both Trial
tests, with the reporter's own fork/exec message as a BlockedError.
Not tried: a real release update end to end on the reporter's machine, or
with a real antivirus holding the file; which program held it isn't known.
macOS Stage shares only the fetch changes.
Users already on 0.1.2364-0.1.2421 run the old updater: after a reboot (the
hold ends) Check for updates usually gets through; otherwise download
magpie from https://usemagpie.ai and open it.