core: resolve default data_dir via XDG_DATA_HOME on non-Windows hosts #1151
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1151"
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 DaniiL35 on 2026-11-24T16:16:09Z.
Resolves #899
Problem
In
crates/victory-core/src/config.rs(line 20),data_diris documented:However,
default_dirresolved both"cache"and"data"using the exact same fallback chain (LOCALAPPDATA->XDG_CACHE_HOME->~/.cache).On Linux and macOS hosts where
VICTORY_DATA_DIRis not set, persistent saves, local storage, and crash logs were placed in volatile cache paths, risking deletion during standard cache cleanup.Fix
XDG_DATA_HOME(and fallback~/.local/share) for"data"on non-Windows hosts before falling back to cache paths.envlookup closure (default_dir_with), allowing pure unit testing of directory resolution.XDG_DATA_HOME,HOME/.local/sharefallback, and WindowsLOCALAPPDATAprecedence.All test inputs are synthetic; zero game data or binary blobs (Rule #1 compliant). Formatted with Rust 2024 edition.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T16:29:03Z.
Review: CHANGES_REQUESTED
Two verified problems on macOS arm64 (rustc 1.98.1, merged into main
ffe310e,cargo test -p victory-core --locked: 9 passed, 5 failed):Empty env vars regress:
empty_env_values_are_ignored,empty_test_titles_env_is_ignored,environment_overrides_file,test_titles_env_splits_pathsnow return Err("cannot determine a user directory"). The.or_elsechain short-circuits onSome("")(e.g. LOCALAPPDATA=""), and the.filter()is applied only after the whole chain, so an empty early var prevents fallback to HOME/XDG instead of being ignored. Filter each candidate before the chain (or map empty -> None per var).Your own new test
localappdata_takes_precedence_for_bothfails on Unix:PathBuf::from(r"C:\Users\User\AppData\Local").join("victory")yields mixed separators (...Local/victory/data) off Windows. Gate that test#[cfg(windows)]or build the expected path with PathBuf joins.Also note #708 (still open) overlaps this config.rs area; worth coordinating so the data-dir fixes land consistently.
Pull request closed