Skip to content

Windows and Linux: an update started at launch no longer loses its staged file - #484

Merged
stevyhacker merged 1 commit into
masterfrom
claude/update-install-race
Nov 11, 2026
Merged

stevyhacker merged 1 commit into
masterfrom
claude/update-install-race

Conversation

@stevyhacker

Copy link
Copy Markdown
Owner

Summary

The app deletes leftover lokalbot.new/.old files 0, 10 and 60 seconds after it starts (install::remove_leftovers, scheduled in lokalbot-app/src/updates.rs). An install under way at one of those moments lost the .new file it had just staged next to the binary, and the rename failed with "could not replace …/lokalbot: No such file or directory". install() now lists the folders it replaces files in until it returns, and remove_leftovers skips listed folders; a cleanup pass holds the list while it deletes, so an install can't start in a folder halfway through one. The list is per folder, so other folders are still cleaned.

Validation

Seen in CI: #482's Linux job on the new self-hosted runner lokalbot-linux-pc (run 42994801514, job 130436132244) failed Check updating from a local feed: lokalbot install-update started at 09:36:57, found the update, and at 09:37:12 logged updates: install failed: could not replace /home/ghrunner/actions-runner/_work/_temp/update-e2e/home/.local/bin/lokalbot: No such file or directory (os error 2), consistent with the 10-second pass deleting lokalbot.new before the swap. The same step passed on the faster server runner, and on lokalbot-linux-pc in #483's run, so it is timing-dependent.

cargo fmt -p lokalbot-update -- --check
# exit 0
cargo clippy -p lokalbot-update --no-default-features --all-targets --locked -- -D warnings
# no warnings
cargo test -p lokalbot-update --no-default-features --locked
# test result: ok. 37 passed; 0 failed (plus 2 in the other test target)

Two new tests in install.rs:

  • cleanup_skips_a_folder_an_install_is_replacing_files_in: while an install lists a folder, its .new and .old files survive a cleanup pass; another folder is cleaned; once the install is done, they go.
  • an_install_waits_for_a_cleanup_pass_and_lists_its_folder_only_while_it_runs: an install started while a pass holds the list doesn't touch the binaries until the pass ends, replaces them afterwards, and leaves the list as it found it.

Mutation check: with the registration line removed from install(), the second test fails (left: "new app", right: "old app").

Run on Linux (Ubuntu 24.04, Rust 1.99.1). Windows uses the same code path; CI's Windows job runs these tests.

Changed test expectations

None (two tests added).

Linked issues

Refs #482

Risk / rollout notes

  • Only lokalbot-update's installer changes. A cleanup pass now skips a folder while an install in this process replaces files there; the .old files a Windows install leaves are removed at the next start, as before.
  • An install now waits for a cleanup pass that is running at that moment (a directory listing and a few deletes).

…aged file

The app deletes leftover lokalbot.new/.old files 0, 10 and 60 seconds after it
starts. An install under way at one of those moments lost the .new file it had
staged next to the binary, and the rename failed with "could not replace
.../lokalbot: No such file or directory". It happened to `lokalbot
install-update` in the update check on a slower CI runner (the install reached
its swap about 15 seconds after launch), and could hit anyone who installs an
update right after starting LokalBot.

install() now lists the folders it replaces files in until it returns, and
remove_leftovers skips listed folders. A cleanup pass holds the list while it
deletes, so an install can't start in a folder halfway through one.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
lokalbot 54df4d6 Commit Preview URL

Branch Preview URL
Nov 11 2026, 10:21 AM

@stevyhacker
stevyhacker marked this pull request as ready for review November 11, 2026 13:07
@stevyhacker
stevyhacker merged commit 605a40c into master Nov 11, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant