Reject persistent data directories inside the cache #194

Open
github-bot wants to merge 2 commits from github-bot/gh-194 into main AGit
Owner

@⁠feanorsun on GitHub · 2026-11-26 11:11 UTC · original
feanorsun:fix/reject-data-dir-under-cache → main · +230 −1 · 5 files · 2 commits · open

Persistent saves can be lost when a user clears the cache. This change checks the final data_dir and cache_dir after each setting has been resolved from the environment, the configuration file, or its default. It rejects equality and descendants. Siblings such as cache and cache-old, and a cache below the data directory, remain valid.

The first commit is an independent port of Luiz Neves's original patch, cherry-picked with -x from c7cf0baafc1cd3f465ae7a4208758c8423fafd71. The same configuration change appeared in the closed upstream PR #103. Original PR and diff · Upstream PR #103

The follow-up covers both directions of a VICTORY_DATA_DIR override. For directories that do not exist yet, it applies Win32 path spelling rules, preserves explicit verbatim paths, and checks the parent directory's case-sensitivity setting when the two spellings differ only in case. The Windows bindings were already in the workspace lockfile.

Windows verification

cargo test --locked -j 1 -p victory-core --lib config::tests:: -- --list
cargo test --locked -j 1 -p victory-core --lib config::tests:: -- --test-threads=1
git diff --check upstream/main...HEAD
  • On upstream main with the environment regression added, 8 tests passed and 1 failed. An override to cache\saves returned a successful configuration.
  • With the original port, the override test passed. A Windows test still reproduced a case-only alias for a missing cache directory on this machine's case-insensitive filesystem. That run had 12 passes and 1 failure.
  • The final filter listed 14 tests. All 14 passed, with 5 filtered out. Coverage includes directories that do not exist yet, .. paths, overrides into and out of the cache, similarly named siblings, and ordinary versus verbatim Windows paths.

Cargo used local dependencies offline. The regressions used temporary directories and injected environment values. Validation was limited to CPU configuration tests.

**@⁠feanorsun** on GitHub · 2026-11-26 11:11 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/194) `feanorsun:fix/reject-data-dir-under-cache` → `main` · +230 −1 · 5 files · 2 commits · open Persistent saves can be lost when a user clears the cache. This change checks the final `data_dir` and `cache_dir` after each setting has been resolved from the environment, the configuration file, or its default. It rejects equality and descendants. Siblings such as `cache` and `cache-old`, and a cache below the data directory, remain valid. The first commit is an independent port of Luiz Neves's original patch, cherry-picked with `-x` from `c7cf0baafc1cd3f465ae7a4208758c8423fafd71`. The same configuration change appeared in the closed upstream PR #103. [Original PR and diff](https://github.com/uiliannn/VItoriaBr/pull/42/files) · [Upstream PR #103](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/103) The follow-up covers both directions of a `VICTORY_DATA_DIR` override. For directories that do not exist yet, it applies Win32 path spelling rules, preserves explicit verbatim paths, and checks the parent directory's case-sensitivity setting when the two spellings differ only in case. The Windows bindings were already in the workspace lockfile. ### Windows verification ```powershell cargo test --locked -j 1 -p victory-core --lib config::tests:: -- --list cargo test --locked -j 1 -p victory-core --lib config::tests:: -- --test-threads=1 git diff --check upstream/main...HEAD ``` - On upstream main with the environment regression added, 8 tests passed and 1 failed. An override to `cache\saves` returned a successful configuration. - With the original port, the override test passed. A Windows test still reproduced a case-only alias for a missing cache directory on this machine's case-insensitive filesystem. That run had 12 passes and 1 failure. - The final filter listed 14 tests. All 14 passed, with 5 filtered out. Coverage includes directories that do not exist yet, `..` paths, overrides into and out of the cache, similarly named siblings, and ordinary versus verbatim Windows paths. Cargo used local dependencies offline. The regressions used temporary directories and injected environment values. Validation was limited to CPU configuration tests.
The cache may be deleted at any time, so persistent data must not live in it.
The reverse (cache inside data) stays allowed. Paths are compared by resolved
components, so cache-old is not inside cache.

(cherry picked from commit c7cf0baafc1cd3f465ae7a4208758c8423fafd71)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:22:13 +00:00
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-26 19:16 UTC · original

Tested locally on Windows 11 (Ryzen 7 8845HS / Radeon 780M, pinned toolchain 1.98.1):

  • cargo test -p victory-core --locked: 19 passed, 0 failed (includes the six new data/cache directory tests)
  • cargo clippy -p victory-core --all-targets --all-features --locked -- -D warnings: clean
  • Cargo.lock change resolves with --locked

Branch is 14 commits behind main; tested as-is.

**@⁠kilolimaVI** on GitHub · 2026-11-26 19:16 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/194#issuecomment-7201393824) Tested locally on Windows 11 (Ryzen 7 8845HS / Radeon 780M, pinned toolchain 1.98.1): - `cargo test -p victory-core --locked`: 19 passed, 0 failed (includes the six new data/cache directory tests) - `cargo clippy -p victory-core --all-targets --all-features --locked -- -D warnings`: clean - `Cargo.lock` change resolves with `--locked` Branch is 14 commits behind main; tested as-is.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/194/head:github-bot/gh-194'
git switch 'github-bot/gh-194'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-194'
git switch 'github-bot/gh-194'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-194'
git switch 'github-bot/gh-194'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-194'
git switch 'main'
git merge --squash 'github-bot/gh-194'
git switch 'main'
git merge --ff-only 'github-bot/gh-194'
git switch 'main'
git merge 'github-bot/gh-194'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.