core: resolve default data_dir via XDG_DATA_HOME on non-Windows hosts #1151

Closed
github-bot wants to merge 1 commit from gh-pr/1151/head into gh-pr/1151/base
Owner

@⁠DaniiL35 on GitHub · 2026-11-24 16:16 UTC · original
fix/config-xdg-data-dir → main · +77 −9 · 1 files · 1 commits · closed without merging

Resolves #899

Problem

In crates/victory-core/src/config.rs (line 20), data_dir is documented:

"What titles write and must keep (persistent local storage). Never inside the cache, which may be deleted at any time."

However, default_dir resolved both "cache" and "data" using the exact same fallback chain (LOCALAPPDATA -> XDG_CACHE_HOME -> ~/.cache).
On Linux and macOS hosts where VICTORY_DATA_DIR is not set, persistent saves, local storage, and crash logs were placed in volatile cache paths, risking deletion during standard cache cleanup.

Fix

  1. Query XDG_DATA_HOME (and fallback ~/.local/share) for "data" on non-Windows hosts before falling back to cache paths.
  2. Parameterize default directory resolution with the env lookup closure (default_dir_with), allowing pure unit testing of directory resolution.
  3. Added 3 synthetic unit tests covering Unix XDG_DATA_HOME, HOME/.local/share fallback, and Windows LOCALAPPDATA precedence.

All test inputs are synthetic; zero game data or binary blobs (Rule #1 compliant). Formatted with Rust 2024 edition.

**@⁠DaniiL35** on GitHub · 2026-11-24 16:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1151) `fix/config-xdg-data-dir` → `main` · +77 −9 · 1 files · 1 commits · closed without merging Resolves #899 ### Problem In `crates/victory-core/src/config.rs` (line 20), `data_dir` is documented: > "What titles write and must keep (persistent local storage). Never inside the cache, which may be deleted at any time." However, `default_dir` resolved both `"cache"` and `"data"` using the exact same fallback chain (`LOCALAPPDATA` -> `XDG_CACHE_HOME` -> `~/.cache`). On Linux and macOS hosts where `VICTORY_DATA_DIR` is not set, persistent saves, local storage, and crash logs were placed in volatile cache paths, risking deletion during standard cache cleanup. ### Fix 1. Query `XDG_DATA_HOME` (and fallback `~/.local/share`) for `"data"` on non-Windows hosts before falling back to cache paths. 2. Parameterize default directory resolution with the `env` lookup closure (`default_dir_with`), allowing pure unit testing of directory resolution. 3. Added 3 synthetic unit tests covering Unix `XDG_DATA_HOME`, `HOME/.local/share` fallback, and Windows `LOCALAPPDATA` precedence. All test inputs are synthetic; zero game data or binary blobs (Rule #1 compliant). Formatted with Rust 2024 edition.
data_dir stores persistent saves, local storage, and logs that must not
be placed in cache folders. On Linux/macOS, default_dir previously resolved
data_dir to XDG_CACHE_HOME or ~/.cache alongside cache_dir.

Resolve data_dir using XDG_DATA_HOME (falling back to ~/.local/share) before
falling back to cache locations, and parameterize default_dir resolution
with the environment closure so default paths are fully testable.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:21:18 +00:00
github-bot closed this pull request 2026-11-26 04:21:18 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1151
No description provided.