fix(config): keep the data directory out of the cache root #708
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!708
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-708"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Loggerten on GitHub · 2026-11-24 07:10 UTC · original
Loggerten:fix/data-dir-outside-cache→main· +109 −14 · 1 files · 1 commits · openWhat
default_dirresolved both the cache and the data directory fromLOCALAPPDATA, thenXDG_CACHE_HOME, then$HOME/.cache. On any host withoutLOCALAPPDATA— Linux, or Windows with it unset — the data directory therefore landed at<cache>/victory/data.Configdocuments the data directory as:So saves could be placed in a root the docs say may be deleted at any time.
Observed
With
HOME=/tmp/probe-home,XDG_CACHE_HOME=/tmp/probe-home/.cache,LOCALAPPDATAunset,Config::load()returned:Fix
Split the two defaults:
LOCALAPPDATAprovides bothvictory/cacheandvictory/data.XDG_CACHE_HOMEor$HOME/.cache; the data directory usesXDG_DATA_HOMEor$HOME/.local/share.The environment-variable and config-file precedence is untouched. Both functions now take the environment lookup as a parameter, so the regression test needs no unsafe environment mutation (edition 2024 makes
set_varunsafe).Test
config::tests::data_dir_not_under_cache_without_localappdataasserts, withLOCALAPPDATAunset:Verification
cargo test -p victory-core— 9 passed, 0 failed.cargo clippy -p victory-core --all-targets— no warnings.rustfmt --checkclean on the changed file.I could only build
victory-coreon this machine:victory-gpuandvictory-hledo not compile on a non-Windows host (E0425: cannot find function host_resource), so I left them alone.`default_dir` resolved both the cache and the data directory from LOCALAPPDATA, then XDG_CACHE_HOME, then `$HOME/.cache`. On any host without LOCALAPPDATA — Linux, or Windows with it unset — the data directory therefore landed at `<cache>/victory/data`, inside a root the docs say may be deleted at any time: /// What titles write and must keep (persistent local storage). Never /// inside the cache, which may be deleted at any time. Split the two defaults. Windows behaviour is unchanged: LOCALAPPDATA still provides both. Elsewhere the cache keeps XDG_CACHE_HOME or `$HOME/.cache`, and the data directory moves to XDG_DATA_HOME or `$HOME/.local/share`. Both take the environment lookup as a parameter, so the new test `data_dir_not_under_cache_without_localappdata` needs no unsafe env mutation. Review fixes: - `env_dir` filters each variable before the `or_else` chain. A set-but-empty LOCALAPPDATA no longer hides XDG_CACHE_HOME / XDG_DATA_HOME, and an empty HOME no longer yields a relative `.cache/victory/cache`. - `empty_test_titles_env_is_ignored` and `test_titles_env_splits_paths`, added on main after this branch point, now give their mock environment a HOME. Without it the mock hid the real environment and resolve() errored. - New tests: empty LOCALAPPDATA falls through to XDG, XDG with no HOME, and an empty HOME errors instead of resolving to a relative path. Existing saves under the old `<cache>/victory/data` are not migrated; set VICTORY_DATA_DIR to that path to keep using them. Verified: cargo test -p victory-core 15 passed, clippy -D warnings clean, cargo xtask policy 154 files ok.@geiyiliyabumo on GitHub · 2026-11-24 09:17 UTC · original
Tested
99f12d904merged withmain(8e79c80, clean git merge) on Windows 11 Pro (26100), Rust1.98.1(x86_64-pc-windows-msvc): needs rebase / fix before merge (2 test failures after mergingmain+ 1 empty-env edge case).1. Silent merge regression against
main(8e79c80)Git merges cleanly (
crates/victory-core/src/config.rs), so the PR appears conflict-free, butcargo test -p victory-core --lockedfails on two tests that were added onmainafter the branch point:config::tests::empty_test_titles_env_is_ignoredconfig::tests::test_titles_env_splits_pathsBoth panic at
Config::resolve(file, None, env).unwrap()with:Because
default_cache_dir/default_data_dirnow readLOCALAPPDATA/HOMEthrough the injectedenvclosure, those two tests also need"HOME"(or"LOCALAPPDATA") in their mockenv, just likeenvironment_overrides_fileandempty_env_values_are_ignored.2. Empty-string env fallback bug in
default_cache_dir/default_data_dirIn both helpers:
.filter(|v| !v.is_empty())is applied after.or_else(...), ifLOCALAPPDATA=""andXDG_CACHE_HOME(orXDG_DATA_HOME) is set,Some("")short-circuits.or_else(...)and is then filtered toNone, skipping the XDG variable entirely. Filtering eachenv(...)lookup individually (e.g., via a smallnon_emptyhelper) avoids this.env("HOME")is not filtered for emptiness, soHOME=""resolves to relative.cache/victory/cacheand.local/share/victory/datainside the current working directory.(Note: on the PR head alone before merging
main,victory-coretests andcargo xtask policypass; the pre-existingvictory-hleclippy warning onxmem.rsis already fixed onmain.)AI-assisted; synthetic tests only, no game files.
@Altorru on GitHub · 2026-11-24 09:59 UTC · original
Review note: the new
LOCALAPPDATA.or_else(XDG_*).filter(non-empty)chain checksLOCALAPPDATAbefore XDG. A set-but-emptyLOCALAPPDATAtherefore prevents an otherwise validXDG_CACHE_HOME/XDG_DATA_HOMEfallback and silently sends the defaults to$HOME. On Unix, gateLOCALAPPDATAoncfg!(windows)(or filter it beforeor_else), and add cases for non-emptyXDG_DATA_HOMEand emptyLOCALAPPDATA. The cache/data separation itself is the right direction.@dcastell1 on GitHub · 2026-11-24 10:16 UTC · original
Two tests fail on current
main@ffe310ewith this PR applied clean:Both are the config tests that previously ran without a user directory; whatever the data-directory change does here now requires one, so the fixtures need
VICTORY_CACHE_DIR/VICTORY_DATA_DIRset (or the fallback kept). The run stops there, so the rest of the workspace did not get to run.On the same box, clean
main@ffe310eis 342 passed, 0 failed, 6 ignored.Environment: Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.98.1, MSVC 14.44.35207, debug build, log outside the tree so the asset-policy test is unaffected. AI-assisted (opencode).
@ErRusso on GitHub · 2026-11-24 11:19 UTC · original
Audit: ✅ Looks good — verified & tested
Reviewed this PR as part of an audit of mergeable PRs. Findings:
crates/victory-core/src/config.rs(+50/-10). Splits the olddefault_dir()intodefault_cache_dir()(XDG cache /%LOCALAPPDATA%) anddefault_data_dir()(XDG data /~/.local/share/%LOCALAPPDATA%), so the data dir is never under the cache root on any platform.main(verified withgit merge-tree).cargo test -p victory-core→ 9/9 passed, including the newdata_dir_not_under_cache_without_localappdata.envclosure parameter makes the default-dir selection testable; existing tests were updated consistently. Good comment explaining the XDG_DATA_HOME default.No issues found. Nice catch separating cache from data.
@Loggerten on GitHub · 2026-11-24 11:24 UTC · original
Pushed
a9698e7, rebased ontoffe310ewith the review fixes. It is a single commit on top of main, so the diff is stillcrates/victory-core/src/config.rsalone.1. The two config tests (catminou4, geiyiliyabumo, dcastell1). Reproduced here:
99f12d9merged withffe310egives 10 passed, 2 failed. Both mock closures hidHOME, soresolve()errored on the new defaults. They now get"HOME" => Some("/tmp/probe-home"), asenvironment_overrides_fileandempty_env_values_are_ignoredalready did. 15/15 pass now.2. Empty env values (geiyiliyabumo, Altorru, mercuryVM). Correct, and slightly worse than reported. The old chain also let an empty
HOMEthrough, which resolved to a relative.cache/victory/cache. There is now anenv_dirhelper that filters each variable before theor_elsechain, andresolveuses the same helper for theVICTORY_*variables. New tests:empty_localappdata_falls_back_to_xdg,xdg_home_without_home,empty_home_is_not_a_relative_path.3. Gating LOCALAPPDATA on
cfg!(windows)(Altorru). Not doing that in this PR. Main'sdefault_diralready preferredLOCALAPPDATAoverXDG_CACHE_HOMEon every platform, so that ordering predates this change. Gating it would change behaviour for Unix hosts that exportLOCALAPPDATA, so it wants its own issue and its own test. The empty-value bug you named in the same paragraph is fixed.4. Migration (mercuryVM). Confirmed, and recorded in the commit message: saves under
<cache>/victory/dataare not moved.VICTORY_DATA_DIRkeeps a user on the old path. Autodetecting the old directory at startup is a bigger change than this PR, but say if you want it.Verified here:
cargo test -p victory-core15 passed,cargo clippy -p victory-core --all-targets -- -D warningsclean,cargo xtask policy154 files ok. I could not runcargo test --workspace:victory-gpudoes not build on Linux on main either (host_resourcemissing atcrates/victory-gpu/src/resource.rs:284), so the workspace run has to come from the Windows CI job.@dcastell1 on GitHub · 2026-11-24 11:38 UTC · original
Follow-up on the current head
a9698e74(based onffe310e): the two failures are gone.empty_test_titles_env_is_ignoredandtest_titles_env_splits_pathsno longer hitcannot determine a user directory, so the rebase fixed what my earlier comment reported against99f12d90/d2a4bae. Four more passing tests than main here, nothing else changes verdict.Environment: Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.98.1, MSVC 14.44.35207, debug, log outside the tree. AI-assisted (opencode).
@molodayamama on GitHub · 2026-11-24 13:58 UTC · original
Independent synthetic Windows check of
a9698e7488(Windows 10 22H2, Rust 1.98.1, MSVC x64).cargo test -p victory-core --locked --lib config::tests -- --test-threads=1 --nocapture passed 11 configuration tests. The changed cases covered cache/data directory separation when LOCALAPPDATA is absent, empty LOCALAPPDATA, XDG_DATA_HOME with HOME missing, and rejection of an empty home instead of a relative path.
No game files or GPU needed. AI-assisted verification.
@Marvisak on GitHub · 2026-11-25 01:28 UTC · original
Automated triage for the maintainers.
Proposed close. The PR splits
default_dirincrates/victory-core/src/config.rsintodefault_cache_diranddefault_data_dir, so that hosts withoutLOCALAPPDATAput data underXDG_DATA_HOMEor~/.local/share. It is careful work, and the review fixes (empty values, test fixtures) are correct.It doesn't change anything on a host VIctory supports, though. VIctory runs only on Windows (README: "Requirements: Windows 10/11 x64"). There
LOCALAPPDATAis always set, and the defaults are already the siblings%LOCALAPPDATA%\victory\cacheand%LOCALAPPDATA%\victory\data, so data is not under the cache root. The new paths only apply wherevictory-gpuandvictory-hledon't build, as the PR itself notes. Making the program usable on non-Windows hosts is out of scope. The PR also moves the default for anyone who relied on the old path, with no migration.If a maintainer wants the XDG defaults anyway, removing the label keeps this open.
CI: no check runs on the head commit.
This pull request will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.