fix: windows in-app uninstall fully wipes the data root (temp-copy cleaner)#323
Merged
Merged
Conversation
Two-phase temp-copy cleaner: the originally-spawned helper copies itself to the context-appropriate OS temp dir (GetTempPath2W), spawns the copy detached with --no-log + --wait-pid, and exits; the temp copy waits for the original to exit, runs Update.exe --uninstall, then removes the dataRoot targets with a bounded retry. Closes the three --wipe leftover mechanisms (running-exe lock, CWD lock, log-dir recreation). Target: v0.1.30-beta.52.
…acy in-place uninstall
- Honor --no-log at main() entry so the cleaner is silent from its first instruction (was only disabling inside run_cleaner, after main()'s preamble had already recreated <dataRoot>/logs — the --no-log flag was inert). - Match the proven detached-survival idiom (DETACHED_PROCESS | CREATE_NO_WINDOW + null stdio) for the cleaner spawn, so it reliably outlives the bootstrapper. - resolve_temp_dir: fail closed on a 0 / buffer-too-small GetTempPath return instead of risking an out-of-bounds slice (panic=abort) on the wipe path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
beta.51 shipped the first in-app Windows uninstall, but its cleanup helper runs from inside the data root it deletes (
%ProgramData%\WsScrcpyWeb\control\operation-server\ws-scrcpy-web-launcher.exe). On a wipe (unchecking "keep my settings & logs") that left the data root behind, via three mechanisms:log::append()doescreate_dir_all(<dataRoot>/logs)on every line, so the helper's own logging recreatedlogs/right after deleting it.The fix — two-phase temp-copy cleaner
All inside the Rust launcher;
ServiceApi.tsis unchanged.run_bootstrap, the helper the server already spawns): resolve the context-appropriate temp dir (GetTempPath2W→ user temp under a user token, hardened system temp under SYSTEM), copy the launcher there, spawn that copy detached (DETACHED_PROCESS | CREATE_NO_WINDOW, null stdio) with--wait-pid <self> --no-log+ the uninstall params, then exit — releasing the running-exe lock. Falls back to the old in-place path if temp/copy/spawn fails.run_cleaner, the temp copy): logging disabled at process entry (--no-log), wait for the original to exit, runUpdate.exe --uninstall, then delete the data-root targets with a bounded retry. It then just lives in temp.All three orphan mechanisms close: the deleter runs from temp, its CWD is temp, and it never logs into the data root.
--keepstill preservesconfig.json+logs.Also in here
v0.1.30-beta.52(it was stale at beta.50) and added the missing Windows in-app-uninstall batch (#16) to the checklist.docs/specs/2026-06-08-windows-uninstall-wipe-self-deletion-design.md,docs/plans/2026-06-08-windows-uninstall-wipe-self-deletion.md.Verification
cargo test: launcher 115, common 49, tray 4 — all green.cargo clippy --all-targets -- -D warningsclean. Full workspace builds on native Windows, so the#[cfg(windows)]paths type-check against windows 0.58.--no-logwired atmain()entry; detached-spawn idiom), verdict APPROVE.Test plan
config.json+logssurvive; reinstall reuses the port%ProgramData%\WsScrcpyWebis gone, includingcontrol\operation-server\(no leftover)