ac4af582301a4e8a29245dbba767eba31334ddf9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
40dee51751 |
update: on Windows a download an antivirus holds is waited for up to 30s, and a restart tried again doesn't trial-start it again (白菜 on Discord)
白菜 (Discord #general, 10-19): with magpie on the Desktop, every click on Update says it is restarting and then offers the update again; clicking again never gets it in, only a fresh download from the site does. Cause, as far as could be shown: the install starts the download suspended first (canStart, #894). An antivirus that checks a program as it starts holds the file a while after, and the move into place gave up after asideWaits' ~3s (#2272's fix). The swap failed, the old exe was put back, the state stayed ready and the pill said 更新失败, with the reason only in its tooltip. A click again ran the trial start again, so the antivirus held the same file again and it failed the same way every time. Change: - moveIn and moveAside go on trying, at the last pause (1.5s), while Windows says the file is held open (errors 32/33), up to heldFor (30s) from the first try. Other errors still stop after the short pauses. - InstallBinaryAside trial-starts a download once: the same path, size and mtime that passed isn't started again on a retry. A new download is. - A download still held after that says so ("another program still has the download open (often an antivirus checking it): let magpie through it…"), without the paths, in the version row and the pill's tooltip. It still unwraps to the *os.LinkError and the sharing violation. Tests: - TestMoveAsideWaitsOutALongHold (all OSes): 10 held tries then success. A permission error still stops at 4. - TestInstallBinaryWaitsOutALongHold (Windows): a real handle holds the download for 600ms against 2 short pauses. - TestInstallBinaryTrialsADownloadOnce (Windows): one trial for a retried download, a second for a new one, and the new error text. - Existing tests that hold a file for good set heldFor to 0. What was run: - Broken by hand (no wait past asideWaits, trial on every try): all three new tests red on the Windows box. TestMoveAsideWaitsOutALongHold is red on macOS too. Restored: green. - Windows box (10.0.26200, Defender on), cross-compiled update.test.exe in a sandbox USERPROFILE/APPDATA/TEMP: the whole internal/update package PASS (41 tests). - Real GUI on the box: a production build (v0.1.9000) at C:\Users\yeton\Desktop\magpie-windows-amd64.exe, a sandbox home, a local feed offering v0.1.9001. The .new was held open from PowerShell (FileShare Read) for 12s, then POST /api/update/install {when:now}: - origin/main's build: install failed, "rename … being used by another process", state ready, old process ran on; - this build: the new version started 1s after the hold was let go, and the Desktop exe's hash is 9001's. - The same setup without a hold, origin/main's build, worked: plain Desktop, and a Desktop folder named 白菜 测试 with "(1)" in the exe name. A non-ASCII path or the Desktop alone is not the cause. - gofmt clean. go vet ./... clean for darwin, linux -tags nogui and windows. - HOME=<sandbox> go test -timeout 45m ./... at load ~260-290: every package ok except these. - internal/agent and internal/gateway timed out at 45m. Already filed as #2544 and #2870. - internal/gui's TestSetAnswersWhileDevinAndProvidersHang (19.8s set under load) is filed as #1375. Rerun alone with the update, restart, install and relaunch tests: ok. - internal/update was rerun separately, because its source was swapped to origin/main's for ~1 min mid-run to build the comparison exe: ok. Not tried: - A real third-party antivirus (360, Huorong). The hold is injected. The user's version, antivirus and exact error are still unknown, and were asked for on Discord. - A OneDrive-redirected Desktop. |
||
|
|
1ca56a9ad8 | fix(update): roll back failed Windows binary installs (#632) | ||
|
|
88cccc184e | update: on Windows, an exe something holds open for a moment still goes aside for the new version, and one held for good says why in full, with the release page a click away (freecss on Discord: "0.1.628 已下载 · couldn't move magpie-windows-amd64.exe aside to put the new version in: rename C:\Us…") — InstallBinary renamed the running exe to .old once and gave up on the first error, which Go prints as "rename <exe> <exe>.old: <reason>", two full paths ahead of the reason, and the version row cut it off on one line, so what failed couldn't be read. A leftover .old was already handled (RemoveOld, then .old-2…, TestInstallBinaryBesideARunningOld), and Windows renames a running image (it is mapped with FILE_SHARE_DELETE), so the likely cause is another program holding the exe open without delete sharing — an antivirus scan, OneDrive or a similar sync client — or a folder that refuses the change (access denied); which one isn't known until the full message is read. moveAside now tries again for about 3 s (0.1, 0.2, 0.4, 0.8, 1.5 s apart), clearing a read-only attribute after the first failure, with a fresh .old name each try; a missing exe isn't retried. When it still can't, the message is the reason without the paths and what to do: ERROR_SHARING_VIOLATION/ERROR_LOCK_VIOLATION says another program has it open (often an antivirus or OneDrive), access denied names the folder Windows won't let magpie change, anything else says to download the new version; the download is kept for another try, as before. The version row wraps a failed install's or download's reason (.sub.wraps) with the whole text as its tooltip, and a ready-but-failed install offers Download, which opens the release page. The Windows test box wasn't reachable from this session (ssh key refused), so nothing ran on Windows; TestInstallBinaryHeldOpen (windows-only: an exe held open without FILE_SHARE_DELETE for 0.5 s still installs; held for good, the error says another program has it open and the download is kept) was cross-compiled with GOOS=windows go test -c but not run. TestMoveAsideTriesAgain and TestMoveAsideSaysWhy (portable, with a fake rename) and the new update-check.test.cjs case (webkit, en and zh: the reason is not cut off, its tooltip is the full text, Download opens the release page, a later state is one line again) fail without the change; Chromium couldn't launch here (its Playwright cache has no ICU data). go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build and vet, go test -tags nogui ./... pass (TestFXInState failed once on a TempDir cleanup race, passes on the rerun; untouched). |