Skip to content

Launcher: the shared-folder cleanup never collides with an earlier cleanup; bounded retries - #53

Merged
phantoslayer21 merged 1 commit into
mainfrom
fix-cleanup-move
Nov 13, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
fix-cleanup-move

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Split out of #46 at review: the shared-folder cleanup fix on its own.

StartCleanup moves %LOCALAPPDATA%\WrongGPU aside and lets a hidden cmd.exe delete it. The target name was
<folder>.cleanup-<pid>-<GetTickCount64()>; that clock moves in steps of about 16 ms, so a second cleanup of the same
folder within one step (an install's restore followed by the last game's uninstall, or Remove data right after an
uninstall) aimed at the first cleanup's folder, which is deleted only seconds later. The move failed with error 183
and the folder was left in place ("Shared data cleanup deferred").

  • The target name adds a process-wide sequence number and is checked free before the move.
  • A sharing violation (32) or an access denied (5: how a folder rename fails while another program, such as a
    scanner, has a just-written file in it open) is tried again, at most 5 times with waits from 50 ms doubling, each
    wait logged with the error. Any other error is final; the deferred line now names the error.
  • Test seam SetCleanupMoveForTest (record.h).

Tested (launcher core CPU tests in the CI configuration, on c793823: source-size, wording, wg-core,
launcher-core, coexist-core pass, 0 compiler warnings; line-ending check). wg-core's new cases, run directly:

  • two cleanups of one folder back to back, 20 runs: 20/20, none deferred;
  • error 5 for 3 tries, then the move: 4 tries, 3 retries logged, the folder goes;
  • error 5 every time: 5 tries, 4 retries logged, one deferred line naming the error, the folder left in place;
  • error 32 for 2 tries, then the move: 3 tries, the folder goes;
  • error 183 once: 1 try, deferred at once.

Not tested

  • The installer and launcher suites (full launcher build) and a real scanner holding a file.

…eanup; bounded retries

StartCleanup moves %LOCALAPPDATA%\WrongGPU aside and lets a hidden cmd.exe delete
it. The target name was <folder>.cleanup-<pid>-<GetTickCount64()>; that clock
moves in steps of about 16 ms, so a second cleanup of the same folder within one
step (an install's restore followed by the last game's uninstall, or Remove data
right after an uninstall) aimed at the first cleanup's folder, which is deleted
only seconds later. The move failed with error 183 and the folder was left in
place ("cleanup deferred").

- The target name adds a process-wide sequence number and is checked free first.
- A sharing violation (32) or an access denied (5: how a folder rename fails while
  another program, such as a scanner, has a just-written file in it open) is tried
  again, at most 5 times with waits from 50 ms doubling, each wait logged with the
  error. Any other error is final; the deferred line now names the error.
- Test seam SetCleanupMoveForTest (record.h).

Tests (wg-core, every build): two cleanups of one folder back to back, 20 runs;
error 5 for 3 tries then success; error 5 every time (5 tries, folder left,
deferred line names the error); error 32 twice then success; error 183 once
(deferred at once).

Split out of #46 at review.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 13, 2026 19:59
@phantoslayer21
phantoslayer21 merged commit 234515a into main Nov 13, 2026
2 checks passed
@phantoslayer21
phantoslayer21 deleted the fix-cleanup-move branch November 13, 2026 19:59
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