Skip to content

Uninstall, Update, Repair and relocation can discard a backup that was meant to be kept #70

Closed

Description

@phantoslayer21

This was found by reading the code. It has not been reproduced.

What happens

Two paths throw away a backup of a file the player had before WrongGPU.

1. Uninstall deletes the backup of a pre-existing file that was changed after install.
In DoRestore (clean/installer/src/wg_core/record.cpp), a copy entry whose live file matches neither the installed hash nor the original hash goes into skip. It gets the warning "Left in place (changed since install)" (record.cpp:472-474). The restore loop then skips it (record.cpp:482). Only the disable branch sets keepBackup (record.cpp:510). A skipped entry that had an original (existed=1) does not. Clean-up then removes the backup folder (record.cpp:566) or the whole state folder (record.cpp:569-572). The original is gone and the player is not told.

This applies to copy entries with existed=1: a player's own OptiScaler files that WrongGPU's OptiScaler replaced, REFramework mirror copies, and wronggpu.ini (see #73). OptiScaler.ini is handled separately (record.cpp:456-460). For FSR slot names, keeping the game's newer DLL is intended (record.cpp:474).

2. Update, Repair and relocation overwrite a backup that the restore kept on purpose.
When a disable entry's path holds different content again, DoRestore sets keepBackup and returns early with a warning (record.cpp:510, 565). It does not return an error. Callers ignore it:

  • DoInstall takes the warnings and carries on (clean/installer/src/wg_core/install.cpp:277). It then runs a fresh, unfiltered FindConflicts (install.cpp:500). detect.cpp:487-495 removes the hosted install's own OptiScaler.log from that list. install.cpp:500 does not. OptiScaler.log is one of the markers (coexist.cpp:21). So the log written by WrongGPU's own OptiScaler becomes a new disable entry (install.cpp:566-570). The backup step then copies over backup\OptiScaler.log (install.cpp:584-591) and SaveRecord replaces the record. The kept original is overwritten.
  • Relocation runs DoRestore(..., keepState=true) and then RemoveTree(StateDir(wrongDir)) (clean/installer/src/wg_core/launcher.cpp:1001-1002).
  • RemoveEarlierDirect does the same (install.cpp:44-50), but only for direct-route records.

When it can happen

1. Uninstall. Rare, but an ordinary player can hit it. Example: a player switched from their own OptiScaler, later drops a newer OptiScaler DLL over WrongGPU's by hand, or hand-edits a wronggpu.ini that existed before, and then uninstalls. What is lost is the pre-install version of a file the player has since replaced. That breaks the "put back byte for byte" promise (launcher.cpp:984-985, coexist.cpp:290), usually for a superseded file.

2. Update or Repair. Yes, for an ordinary player in the common case. Someone who had their own OptiScaler with an OptiScaler.log, switched to WrongGPU, played once, and then ran Update or Repair loses the pre-switch OptiScaler.log. That is a log, so low value, but it is the "kept in the backup" promise being broken. Worse cases need a real player file to reappear at a disabled path, for example the player reinstalls their own OptiScaler under another proxy name. That is unusual but innocent. Relocation needs the misplaced-install case together with such a file.

Related: #23.

To do

  • In the check pass of DoRestore, when a skipped entry has existed and is not an FSR slot name, set keepBackup = true. Add a warning that names the kept file and the backup path. The existing early return at record.cpp:565 then keeps the record and the backup.
  • Make DoRestore report an incomplete restore in a way callers cannot ignore. For example, return a flag, or throw a dedicated SetupError code, when keepBackup is set and keepState is true. DoInstall, the relocation at launcher.cpp:1001 and RemoveEarlierDirect then stop before RemoveTree or the new backup pass, with a message that names the file.
  • Leave OptiScaler.log out of the conflict scan at install.cpp:500 for a hosted record, as detect.cpp:491 does. The routine case then never triggers.
  • Cheaper alternative to a new refusal path: move the kept generation to backup.kept-<stamp>\ before the new install starts.
  • Cautions: the state folder will stay behind more often after uninstall. That is the safe side, but the next install has to cope with a leftover record. Updates will refuse more often until the player deals with the conflicting file (not with the alternative above).

Test

CPU-only.

  • Uninstall: fake game with an existing dxgi.dll (A). Install, overwrite dxgi.dll with C, uninstall. Assert C is in place and a file with A's bytes still exists in the backup.
  • Update: fake game with the player's own OptiScaler.log (A) and an OptiScaler marker. Install with move-mods, write a different OptiScaler.log (B), run Update. Assert a file with A's bytes still exists under wronggpu-setup.

Activity

  1. added this to the 0.6.1 milestone on Nov 13, 2026
  2. added a commit that references this issue on Nov 13, 2026
  3. moved this from Todo to In Progress in WrongGPUon Nov 13, 2026
  4. moved this from In Progress to Done in WrongGPUon Nov 14, 2026
  5. phantoslayer21 commented on Nov 15, 2026

    @phantoslayer21
    OwnerAuthor

    Verified against main (e231746): fixed by #47, which closed this issue on merge.

    DoRestore in clean/installer/src/wg_core/record.cpp now plans every entry before it changes anything. When it can't put a file back (the file changed since the install, or a disable path that holds other content again), it first copies the original into WrongGPU-originals\<stamp>\ (KeptOriginal) and says "Partly restored: ... is kept in ...". Uninstall, Update, Repair, the move out of a wrong folder and RemoveEarlierDirect all go through that path, so cleaning up the backup or state folder can no longer discard an original.

    Tests in clean/installer/tests/coexist_061_tests.py:

    • test_ownership_matrix: uninstall, repair, update and relocation, each for wronggpu.ini, OptiScaler.ini and OptiScaler.log. A and B both survive, and A is in WrongGPU-originals.
    • test_backups_kept: Update and Repair after WrongGPU's OptiScaler wrote its log, and relocation with another OptiScaler DLL in place.

    CI also runs the launcher-core "ownership: ..." checks. #47 records run_coexist_tests.py at 229 passed, 0 failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: launcherLauncher and installerbugSomething isn't working

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions