fix(config): keep the data directory out of the cache root #708
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Loggerten on 2026-11-24T07:10:49Z.
What
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.Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T07:38:50Z.
Review: APPROVED
Tested on Windows 11 MSVC (rustc 1.98.1):
Separating \default_cache_dir\ and \default_data_dir\ properly enforces that user saves/persistent data never end up under the cache root when \LOCALAPPDATA\ is unset.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T08:04:30Z.
Review: APPROVED
cargo test -p victory-core --lockedon macOS 26 arm64, rustc 1.98.1, head99f12d9: 9 passed / 0 failed (+1 vs main's 8 — the new data-dir test runs ungated). The split intodefault_cache_dir/default_data_dirwithXDG_DATA_HOMEsupport and empty-env filtering is the right shape, and the&dyn Fnseam makes it testable. Approving.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T09:04:41Z.
Review: CHANGES_REQUESTED
Rebase note: textually clean against current main (
8e79c80), but the merge is semantically broken —cargo test -p victory-corefails 2 tests:Those two tests come from main (#611) and inject an
envclosure that only knowsVICTORY_TEST_TITLES. This PR routes the cache/data defaults through that same injected closure (default_cache_dir(&env)/default_data_dir(&env)), so with noHOME/XDG_*/LOCALAPPDATAin the closure the resolve now errors where main'sdefault_dirused to read the real process environment.Verified fix (12/12 green on macOS arm64, rustc 1.98.1): give the two closures a
HOMEarm, exactly like this PR already does forenvironment_overrides_fileandempty_env_values_are_ignored:With the new Windows CI (
cargo test --workspace), this would fail there too — the injected closure hides the real environment on every platform.Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T09:17:31Z.
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.
Imported from Marvisak/VIctory. Originally posted by Altorru on 2026-11-24T09:59:46Z.
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.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T10:20:45Z.
Review: APPROVED
Tested
99f12d9on Windows 11, RTX 5070, MSVC:cargo test -p victory-core9 passed, includingdata_dir_not_under_cache_without_localappdata.cargo clippy -p victory-core --all-targetsis clean.envclosure in makes both defaults testable without changing process state, and the Windows path, which usesLOCALAPPDATAfor both, is unchanged..filter(|v| !v.is_empty())runs after theor_elsechain. WhenLOCALAPPDATAis set but empty, the chain stops there, soXDG_CACHE_HOME/XDG_DATA_HOMEis never tried and the result falls straight toHOME. Filtering each variable before chaining (env("LOCALAPPDATA").filter(..).or_else(|| env("XDG_DATA_HOME").filter(..))) would honour XDG in that case.LOCALAPPDATAand noVICTORY_DATA_DIR, existing saves at<cache>/victory/datawon't be picked up from the new location.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T10:16:27Z.
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).
Imported from Marvisak/VIctory. Originally posted by ErRusso on 2026-11-24T11:19:18Z.
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.
Imported from Marvisak/VIctory. Originally posted by Loggerten on 2026-11-24T11:24:11Z.
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.Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T11:38:06Z.
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).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T12:18:34Z.
Review: APPROVED
Re-tested
a9698e7on Windows 11, RTX 5070, MSVC:cargo test -p victory-core15 passed, includingdata_dir_not_under_cache_without_localappdataand the newempty_localappdata_falls_back_to_xdg.This covers the nit from my previous review:
env_dirnow filters each variable for emptiness before chaining, so an emptyLOCALAPPDATAfalls through toXDG_*and then toHOME, for both the cache and the data dir.data_dirunder the cache problem (I requested changes there for two broken tests). This one is the more complete of the two.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by molodayamama on 2026-11-24T13:58:54Z.
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.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:28:58Z.
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
Pull request closed