fix(updates): the swap waits for a new launcher still held after its self-check #228
No reviewers
Labels
No labels
area/build
area/install
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!228
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/LongshotLauncher:fix/self-update-held"
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?
The launcher could not update itself on Windows: the new launcher is still held for a moment after its
--self-checkhas ended, so the rename that puts it in place fails with "being used by another process", and the player sees only that error.Fixes #223
Summary
--self-checkchild prints its version and returns at the top ofMain; it starts nothing and holds nothing once it has ended, and the launcher closes all its own handles on the.newbefore starting it. So whatever holds it 500 ms later is another process opening a program it has just seen run, most likely an antivirus scan (Defender), and it lets go soon after: at the next start,Recoverdeletes the same.newwith no trouble. The log shows two failures:Swap's move (logged without a path:File.Move's message), then thefinally'sFile.Delete(staged), whose message, with the path, replaced the first one and is what Home showed.SelfUpdate.WhileHeld. On Windows, the move of the new launcher into place is tried again while it fails as held (sharing violation, lock violation, or the access denied thatFile.Movethrows as anIOException), waiting 0.1 s, then 0.25, 0.5, 1 and 2 s, about 10 s in all. Any other failure is thrown at once, and the one before is still put back when it times out.UpdateLauncherAsyncruns the swap inTask.Run, so these waits don't freeze the window.SelfUpdate.Discard. The staged file's cleanup no longer throws: when it cannot be deleted yet it is logged and left for the next start'sRecover, and the update's own error is the one shown.Launchers up to v1.1.0 run their own swap code, so this helps updates from the release that has it. A v1.0.0 or v1.1.0 launcher that fails can try again, or the player can unpack the new portable zip over it.
Testing
python -I tests/test_launcher_core.py: 2608 checks passed. The new checks giveWhileHeldWindows' HRESULTs asFile.Movethrows them: it moves once the file is let go, gives up after the waits with the error, and throws other errors at once. They also check that a Windows swap with nothing held does not wait, and thatDiscardleaves a file it cannot delete without throwing.LAUNCHER=$PWD python -I ../Tooling/tests/test_release.py: 3 failures (test_the_bump,test_the_next_stable,test_check_tag_against_the_published_releases), the same 3 onmainwithout this change, as they read this repository's tags. This change touches nothing of the release format.dotnet build App: no warnings.🤖 Generated with Claude Code