Skip to content

Commit 3fd8fc7

Browse files
Converter ignore lists: a player's list is never lost; recorded source matched as recorded
Second review, round 3: - PutIgnoreListBack returns ListKept. When another program made ignore-files.txt again meanwhile, the player's list is kept beside it as ignore-files.txt.kept-<n>; when it can't leave the moved-aside folder, it stays there and no cleanup deletes that folder's tree (StartCleanup, RemoveSharedData, SelfUninstall). A list that is a link is moved as the link. The player's result says where it is. - RecordedSourceReason compares the recorded path text (normalised) and the stored SHA-256 with the entry; the recorded path is never opened again. An old record without a SHA-256: the path text alone decides. - --ignore-list is read once by the lists' bounded reader (ReadIgnoreListBytes); the search parses those bytes. - When every file found is ignored, the message names the first file with its list and line and points to the log; an unreadable list's message says fix or delete it. Tests on each cleanup path (unit tests with a seam and a private registry hive; command-line suite with WRONGGPU_TEST_LIST_PUTBACK), retargeted source cases for model and RR data, the 16 MB --ignore-list case. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
1 parent 122b7a4 commit 3fd8fc7

13 files changed

Lines changed: 556 additions & 92 deletions

File tree

‎clean/installer/README.md‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ Reconstruction data; the window, the install, `model convert`, `rr-data convert`
382382
- `ignore-files.txt` in the launcher's own data folder when that is another folder: `WrongGPU-data\ignore-files.txt` next to
383383
a portable launcher, or the `--data=` folder.
384384

385-
`model convert` and `rr-data convert` add `--ignore-list=<file>` (repeatable; a file that can't be read stops the command,
385+
`model convert` and `rr-data convert` add `--ignore-list=<file>` (repeatable; read once, by the same bounded reader as the
386+
well-known lists, so a file of 16 MB or more is refused before it is read; a file that can't be read stops the command,
386387
exit 10, nothing converted) and `--ignore=<entry>` (repeatable; one line of the format below, `--ignore=<path>`,
387388
`--ignore=<path> sha256=<hex>` or `--ignore=sha256=<hex>`; an entry that is not understood stops the command, exit 10). For
388389
both the `=` is required: a bare `--ignore` or `--ignore-list` is an error (exit 10) and never takes the next argument as
@@ -432,7 +433,10 @@ is not converted: it is on the ignore list <file>, line <n> (path ...)" or "...
432433
remove that line if it was listed by mistake (the result's `notes`, the install's warnings, the error when nothing else was
433434
found). Every skipped file is named with the reason (the list and its line, or the `--ignore=` argument, and the path or the
434435
hash) in the log (`model: skipped ...`, `RR data: skipped ...`), on the console and in the JSON result (`skipped`,
435-
`ignore_warnings`). When every file found is on a list, nothing is converted, the message says so and the exit code is 5.
436+
`ignore_warnings`). When every file found is on a list, nothing is converted and the exit code is 5; the message itself names
437+
the first file skipped with its list and line (or `--ignore=` argument), says how many others were skipped and where the log
438+
is, and to remove that line if it names a file that came with one of the player's own games. A list another program wrote
439+
never switches the conversion off without the player being told which file did it.
436440

437441
"An empty list, or none, changes nothing" means the **choice of file**: the candidates, their order and so the file that
438442
converts first are the same (`tests/convert_ignore_tests.cpp` runs the real candidate search with no list and with an
@@ -443,7 +447,8 @@ more in that file; the converted data itself is unchanged.
443447
**A list that can't be read fails closed.** A well-known list that is there but can't be read (another program holds it
444448
open without sharing, no permission, a folder of that name, a name the system refuses) is tried 5 times, 200 ms apart, when
445449
the cause is a sharing violation (an installer may be writing it); still unreadable, nothing is converted or reused, the
446-
message names the file and the reason, and the exit code is 10 (`model convert`, `rr-data convert`, and an install or
450+
message names the file and the reason and says what to do (close the program that holds it, or fix the file or delete it),
451+
and the exit code is 10 (`model convert`, `rr-data convert`, and an install or
447452
repair, whose model check fails with it). So does a list that can't be decoded: only UTF-8 and UTF-16 LE with its BOM are
448453
read (UTF-16 big-endian, UTF-16 without a BOM and bytes that are not UTF-8 are not guessed at). A list that isn't there
449454
(file or folder not found) is simply not read. A candidate whose SHA-256 can't be computed (it can't be read) while a hash
@@ -460,16 +465,27 @@ list has entries:
460465
why, and an RR game's install goes on with RR off and a warning. The file itself is not deleted (other installed games'
461466
runtime reads it; nothing in the runtime changed). Data converted from a legitimate copy that has the same bytes as a
462467
listed file, at another path, is reused.
463-
- no SHA-256 is on record (converted by 0.6.0 or earlier): unknown; converted again when an allowed file is found, else kept
464-
with a warning for the player.
468+
- The recorded source is compared **as it was recorded**: the recorded path's text (normalised: case, `/` or `\`, `.`, `..`)
469+
with the entry's path, as written and as it resolves now, and the recorded SHA-256 with the entry's. The recorded path is
470+
never opened again: if it was later replaced by a hard link or a symbolic link to a listed file, the data converted from
471+
the file that was there then is still reused.
472+
- no SHA-256 is on record (converted by 0.6.0 or earlier): the path text alone decides (a path + hash entry naming the
473+
recorded path lists it, since its bytes can't be checked); not listed, it is unknown: converted again when an allowed file
474+
is found, else kept with a warning for the player.
465475
With no list entries, a conversion is reused exactly as before.
466476

467477
**The uninstalls keep the list.** `remove-data` (and the window's Remove data), the launcher's uninstall (`self-uninstall`,
468478
Apps & features) and the last game's uninstall (also through a game's own restorer) remove `%LOCALAPPDATA%\WrongGPU` as
469479
before but put `ignore-files.txt` back in it, and say "kept ignore-files.txt (your/integrators' ignore list): <path>" (the
470480
console and `kept` in `remove-data`'s result; the uninstall's output and log; a game uninstall's result warnings; the
471481
window's toast). The launcher's own data folder's list (portable, `--data=`) was never removed and is now named the same way.
472-
Without a list, the folder goes as before.
482+
Without a list, the folder goes as before. **A player's list is never deleted**: when another program made
483+
`ignore-files.txt` again between the folder's move and the put-back, the player's list is kept beside it as
484+
`ignore-files.txt.kept-<n>` (the first free n; WrongGPU reads only `ignore-files.txt`, so the result says to copy the lines
485+
still needed into it); when it can't be moved or copied out at all (a file where the folder should be), it stays in the
486+
moved-aside folder, everything else in that folder goes, nothing deletes that folder's tree, and the result names where it
487+
is. A list that is a link is moved as the link (what it points to is never touched). The tests drive each cleanup path
488+
(`StartCleanup`, `RemoveSharedData`, `SelfUninstall`) through both cases.
473489

474490
A `WRONGGPU_TESTING` build has `rr-data prepare [--library=<folder>]`: the install's RR data step (reuse when the lists allow
475491
it, else convert) without a game, for the tests.

‎clean/installer/src/app/cli.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,21 @@ static std::vector<StoreGame> ConvertLibraries(const Args& a, bool noScan) {
509509
// converted (a file meant to be skipped is never converted because of a typo); a bad line inside a list is skipped with a warning.
510510
static bool ConvertIgnoreArgs(const Args& a, Output& o) {
511511
g.ctx.ignoreListFiles.clear();
512+
g.ctx.ignoreListBytes.clear();
512513
g.ctx.ignoreEntries.clear();
513514
auto refuse = [&o](const wstring& msg) { o.code = EXIT_USAGE; o.j.S("error", msg); Print(msg); return false; };
514515
// a bare --ignore / --ignore-list (no "=", or nothing after it): never takes the next argument as its value
515516
if (a.has(L"ignore")) return refuse(L"--ignore needs its entry after an equals sign: --ignore=<full path> or --ignore=sha256=<hex>; nothing was converted");
516517
if (a.has(L"ignore-list")) return refuse(L"--ignore-list needs its file: --ignore-list=<file>; nothing was converted");
517518
for (auto& f : a.ignoreLists) {
519+
// read once, with the lists' own bounded reader (the size is checked before anything is read); the search parses
520+
// these bytes (LoadConvertIgnore), it does not read the file again
518521
const wstring full = FullPath(f);
519522
string bytes;
520-
if (!IsFile(full) || !ReadAll(full, bytes)) return refuse(L"--ignore-list=" + f + L": the file can't be read (" + full + L"); nothing was converted");
523+
wstring why;
524+
if (!ReadIgnoreListBytes(full, bytes, why)) return refuse(L"--ignore-list=" + f + L": the file can't be read (" + full + L": " + why + L"); nothing was converted");
521525
g.ctx.ignoreListFiles.push_back(full);
526+
g.ctx.ignoreListBytes.push_back(std::move(bytes));
522527
}
523528
for (auto& s : a.ignores) {
524529
IgnoreEntry e;

‎clean/installer/src/app/ui_words.cpp‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,9 +764,13 @@ void RemoveDataAsked() {
764764
InformDetails(L"WrongGPU's data couldn't be removed.\n\nA file in it may be in use. Close what uses it, then try again. Nothing was removed.", kIconError, *why);
765765
return;
766766
}
767-
// the ignore list stays (convert_ignore.h): said once in the toast
768-
ShowToast(kept->empty() ? L"WrongGPU's data is removed. You can delete this portable copy once you close it."
769-
: L"WrongGPU's data is removed; kept ignore-files.txt (your/integrators' ignore list). You can delete this portable copy once you close it.", 1);
767+
// the ignore list stays (convert_ignore.h): said once in the toast; kept elsewhere than in place (another program's new
768+
// list was there, or it could not be put back): where it is, in full
769+
if (!kept->empty() && !StartsWithI(*kept, kKeptIgnoreListText))
770+
Inform(L"WrongGPU's data is removed, but your ignore list was not put back as it was\n\n" + *kept, 1);
771+
else
772+
ShowToast(kept->empty() ? L"WrongGPU's data is removed. You can delete this portable copy once you close it."
773+
: L"WrongGPU's data is removed; kept ignore-files.txt (your/integrators' ignore list). You can delete this portable copy once you close it.", 1);
770774
StartHealth(false); // the model and RR data are gone: the status line and Settings follow
771775
Invalidate();
772776
}

‎clean/installer/src/wg_core/context.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ struct Context {
9494
// command line (--ignore-list=<file>, --ignore=<entry>), added to the well-known lists.
9595
wstring ownDataDir;
9696
std::vector<wstring> ignoreListFiles, ignoreEntries;
97+
// ignoreListBytes[i]: the bytes of ignoreListFiles[i] when the command line read them already (once, with the bounded
98+
// reader: convert_ignore.h ReadIgnoreListBytes); a file without them is read when the search loads the lists.
99+
std::vector<string> ignoreListBytes;
97100
Context() = default;
98101
Context(const Context&) = delete;
99102
Context& operator=(const Context&) = delete;

0 commit comments

Comments
 (0)