Skip to content

Core host UX: XDG data dir, config-relative paths, and clearer VICTORY_LOG handling - #241

Closed
SkippySteve wants to merge 97 commits into
Marvisak:mainfrom
SkippySteve:SkippySteve/core-xdg-data-dir
Closed

SkippySteve wants to merge 97 commits into
Marvisak:mainfrom
SkippySteve:SkippySteve/core-xdg-data-dir

Conversation

@SkippySteve

@SkippySteve SkippySteve commented Nov 24, 2026 •

Copy link
Copy Markdown

Host-side UX fixes in victory-core for where Victory keeps files and how it reports its settings. This PR now also includes #243, which changed the same function, #277, which makes victory config show the data folder, and #266, which warns when VICTORY_LOG/RUST_LOG does not parse. #243, #277 and #266 are closed in its favour.

Problem

  1. Config::data_dir is documented as "never inside the cache, which may be deleted at any time". Without LOCALAPPDATA (a native non-Windows host, e.g. the Linux crates/tools), default_dir used the cache base for both, so the default data dir was $XDG_CACHE_HOME/victory/data (~/.cache/victory/data). Clearing ~/.cache, as desktop cleaners and users routinely do, would delete what titles saved.
  2. A base variable that was set but empty (XDG_CACHE_HOME=, common in shells and wrapper scripts) or relative still won. The base then became relative to the working directory, usually the repo checkout, and cache_subdir failed with the asset-policy error instead of using ~/.cache.

Change (crates/victory-core/src/config.rs only)

  • With an absolute LOCALAPPDATA: unchanged (…\victory\cache, …\victory\data).
  • Without it: cache → $XDG_CACHE_HOME/victory (else ~/.cache/victory), data → $XDG_DATA_HOME/victory (else ~/.local/share/victory).
  • Empty or relative LOCALAPPDATA / XDG_CACHE_HOME / XDG_DATA_HOME / HOME values are skipped and the next candidate is tried, as the XDG spec asks. If none is usable you get the existing "set VICTORY_CACHE_DIR and VICTORY_DATA_DIR" error.
  • default_dir now reads through the same env closure that Config::resolve already takes, so the defaults can be unit-tested. load() still passes the real environment.
  • VICTORY_CACHE_DIR / VICTORY_DATA_DIR and victory.toml still take precedence.

Tests (hermetic: none read the host's real HOME/XDG_*/LOCALAPPDATA, and they use C:\… paths on Windows so they stay absolute)

  • local_app_data_holds_cache_and_data, data_is_not_under_the_xdg_cache, empty_or_relative_values_are_ignored, default_dir_prefers_localappdata_then_xdg_then_home, no_user_directory_is_an_error.
  • The two existing resolve tests now get HOME through the closure. Before, they failed under env -u HOME.

Validated on Linux (config part): cargo test -p victory-core passes, and also passes with HOME, XDG_CACHE_HOME and XDG_DATA_HOME unset. cargo clippy -p victory-core --all-targets -- -D warnings is clean for the host and for x86_64-pc-windows-msvc. config.rs passes rustfmt, and cargo xtask policy is ok. I haven't run it on Windows. No game data was used.

victory config shows the data folder (was #277, apps/victory/src/main.rs)
The data folder (saves, settings, crashes.log) is resolved by Config like the cache folder, but victory config neither printed it nor ran the outside-the-repository check on it, so a VICTORY_DATA_DIR or [paths].data_dir pointing into the source tree went unreported. It now prints data_dir and checks it with ensure_outside_repo alongside cache_dir. Two lines; apps/victory does not yet build on Linux (#235), so this part is checked by review only.

Warn when VICTORY_LOG / RUST_LOG does not parse (was #266, crates/victory-core/src/logging.rs)
A filter that tracing-subscriber rejects, for example VICTORY_LOG=victory_loader=loud, was dropped silently and the binary logged at its default level, so a typo looked like the target had nothing to log. logging::init now prints one line on stderr naming the variable, its value and the parse error, then falls back to the default level as before:

victory: ignoring VICTORY_LOG="victory_loader=loud" (...); logging at "info"

Picking the filter moves into choose_filter, so it can be tested without changing the process environment. Precedence is unchanged (VICTORY_LOG, then RUST_LOG, then the default). Five new tests: unset, VICTORY_LOG over RUST_LOG, the RUST_LOG fallback, and a bad value in each variable.

Config file paths and empty variables (config.rs, victory.example.toml)

  • Relative paths in the config file (game_dir, cache_dir, data_dir, test_titles) are now relative to the file. Before, with VICTORY_CONFIG pointing at another folder, cache_dir = "cache" landed under the working directory, which is often the repository, so the asset policy refused it. ./victory.toml behaves as before.
  • An empty VICTORY_CONFIG counts as unset instead of failing with "points at , which does not exist". An empty VICTORY_TEST_TITLES no longer replaces the file's list with nothing. The other VICTORY_* variables already ignored empty values.
  • victory.example.toml says this and gives the right VICTORY_TEST_TITLES separator (; on Windows, : elsewhere).
  • Tests: relative_file_paths_are_relative_to_the_file, the_default_config_file_keeps_paths_as_written, empty_test_titles_variable_falls_back_to_the_file.

Logging: empty filters and the diagnostics cap (logging.rs)

  • An empty (or blank) VICTORY_LOG/RUST_LOG counts as unset. Before, VICTORY_LOG= made an empty filter that hid everything but errors and also hid RUST_LOG.
  • A filter asking for debug or trace on a build without the diagnostics feature was capped at info without saying so. It now prints one line on stderr: victory: the log filter asks for trace output, but this build logs info and above; rebuild with --features diagnostics for debug and trace.
  • Tests: empty_values_count_as_unset, a_filter_above_the_cap_is_reported.

~ in configured paths (config.rs, victory.example.toml)

  • Neither TOML nor a quoted shell value expands ~. So game_dir = "~/Games/gta" in victory.toml named a folder literally called ~ next to the file, and VICTORY_GAME_DIR="~/Games/gta" named one under the working directory. That's an easy mistake on Linux/Proton setups.
  • A leading ~ component in [paths] values and in VICTORY_GAME_DIR/VICTORY_CACHE_DIR/VICTORY_DATA_DIR/VICTORY_TEST_TITLES now means the home directory: HOME, else USERPROFILE, if it is absolute. ~user/… and a ~ that is not the first component are left as written. A leading ~ with no usable home directory is refused (see below).
  • Tests: a_leading_tilde_is_the_home_directory, tilde_in_the_file_is_home_not_next_to_the_file, tilde_in_variables_is_home, home_dir_falls_back_to_userprofile_and_skips_relative.

VICTORY_CONFIG as a folder, non-UTF-8 log variables, Linux defaults (config.rs, logging.rs, victory.example.toml)

  • VICTORY_CONFIG pointing at the folder that holds victory.toml was reported as "which does not exist". It now says … which is a folder, not a config file; did you mean <folder>/victory.toml? (the hint only when that file is there). The file lookup moves into config_file so it can be tested.
  • A VICTORY_LOG/RUST_LOG value that is not valid UTF-8 was dropped silently by std::env::var(..).ok(). It is now reported on stderr (victory: ignoring RUST_LOG="w\xFF": it is not valid UTF-8) and treated as unset.
  • victory.example.toml gave only the %LOCALAPPDATA% defaults. It now also gives the Linux ones ($XDG_CACHE_HOME/victory or ~/.cache/victory, $XDG_DATA_HOME/victory or ~/.local/share/victory) and says VICTORY_CONFIG names the file, not its folder.
  • Tests: victory_config_must_name_a_file (uses a folder under the system temp dir), a_non_utf8_variable_is_reported_and_unset.

The data folder must not be inside the cache (config.rs, victory.example.toml)

  • data_dir is documented as never inside the cache, but explicit settings could still put it there, e.g. VICTORY_CACHE_DIR=~/victory with VICTORY_DATA_DIR=~/victory/data, or VICTORY_CACHE_DIR=~ with the default ~/.local/share/victory. Clearing the cache would then delete saves.
  • Config::resolve now fails with the data folder … is inside the cache folder …, which may be deleted at any time; set VICTORY_DATA_DIR or [paths].data_dir to a folder outside it. It compares the paths as written, so nothing has to exist yet. A sibling like /v-data next to /v is allowed, and so is the cache inside the data folder.
  • Test: data_inside_the_cache_is_refused. tilde_in_variables_is_home now sets the cache to ~/cache, because a cache of ~ would hold the default data folder.

~ in VICTORY_CONFIG (config.rs, victory.example.toml)

  • The other path variables expand a leading ~, but VICTORY_CONFIG did not, so a quoted VICTORY_CONFIG="~/victory.toml" failed with VICTORY_CONFIG points at ~/victory.toml, which does not exist. It now goes through the same expand_home (via a small explicit_config helper, so it can be tested without touching the real environment); empty still counts as unset. load() resolves the home directory once and reuses it.
  • Test: victory_config_expands_tilde_and_ignores_empty. This also covers what open Config: ignore an empty VICTORY_CONFIG #363 asks for (empty VICTORY_CONFIG), which this PR already did.

Validated (whole PR) on Linux: cargo test -p victory-core passes (33 tests), also with HOME/XDG_CACHE_HOME/XDG_DATA_HOME unset and with --features diagnostics. cargo clippy -p victory-core --all-targets -- -D warnings is clean with and without --features diagnostics, and for x86_64-pc-windows-msvc. cargo fmt -p victory-core --check is clean and cargo xtask policy is ok.

Say where each setting came from (config.rs, apps/victory/src/main.rs)

  • With a variable, the config file and a default for every path, it was not obvious which one won, and the data-inside-cache error did not say which setting to change.
  • Config now has origins (Origin::Env("VICTORY_CACHE_DIR"), Origin::File or Origin::Default) for game_dir, cache_dir, data_dir and test_titles. Empty variables still count as unset and are never the origin.
  • victory config prints it next to each value, e.g. cache_dir : /home/me/.cache/victory [default].
  • The data-inside-cache error now reads the data folder … (from default) is inside the cache folder … (from config file) ….
  • Tests: origins_name_the_setting_that_won, data_inside_the_cache_names_both_origins. With them, cargo test -p victory-core passes 33 tests (also with HOME/XDG_* unset and with --features diagnostics). clippy -D warnings is clean for the host, with diagnostics, and for x86_64-pc-windows-msvc. fmt is clean and cargo xtask policy is ok. As before, the main.rs lines are checked by review only (Build: gate Windows-only paths so the workspace builds and tests on Linux #235).

Refuse a Windows drive path on a non-Windows host (config.rs, victory.example.toml)

  • victory.example.toml ships game_dir = 'D:\victory-data\game'. On Linux that is not absolute, so a copy used unedited was anchored under the config file's folder (usually the repository) and only showed up later as a policy violation or a folder that does not exist.
  • [paths] values and VICTORY_GAME_DIR/VICTORY_CACHE_DIR/VICTORY_DATA_DIR/VICTORY_TEST_TITLES are now checked before use. On a non-Windows host, X:, X:\… or X:/… fails with [paths].game_dir is D:\victory-data\game, a Windows path, but this host is not Windows; set it to a path on this machine (in <file>). VICTORY_TEST_TITLES is checked before it is split, because : would cut D:\a in two. Windows is unchanged. The example file now says its paths are Windows examples.
  • Test: windows_drive_paths_are_refused_off_windows. On Linux cargo test -p victory-core passes 34 tests, also with HOME/XDG_* unset and with --features diagnostics. clippy -D warnings is clean for the host, with diagnostics, and for x86_64-pc-windows-msvc. fmt is clean and cargo xtask policy is ok.

A [paths] key at the top level of the config file (config.rs)

  • game_dir = '/games/gta' with no [paths] header (an easy first victory.toml), or a key written above the header, failed with only unknown field \game_dir`, expected `paths`. It now says game_dir must be under the [paths] table: put a `[paths]` line above it (see victory.example.toml), naming every misplaced key. Other parse errors ([path], gamedir = ...`) keep toml's own message.
  • Test: top_level_path_keys_say_where_they_belong; example_config_parses goes through the same parser. On Linux cargo test -p victory-core passes 35 tests, also with HOME/XDG_* unset and with --features diagnostics. clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

. and .. in the data/cache check (config.rs)

  • The data-inside-cache check compared the paths as written, so VICTORY_DATA_DIR=~/.cache/victory/../data (a sibling of the cache) was refused, and a cache of ~/victory/tmp/.. was not seen to hold ~/victory/data. Both paths now have . and .. folded lexically before the comparison (lexical). It still does not touch the disk or follow symlinks, and the error still shows the paths as written.
  • Tests: data_inside_the_cache_ignores_dot_dot, lexical_folds_dot_and_dot_dot. On Linux cargo test -p victory-core passes 37 tests, also with HOME/XDG_* unset and with --features diagnostics (run with TMPDIR outside the repository, which policy::tests::accepts_unrelated_directories needs). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

Keep the game folder apart from the cache and data folders (config.rs, victory.example.toml)

  • The game folder is the user's own dump and is only read. Nothing stopped it from being inside the cache (VICTORY_CACHE_DIR=~/gta with VICTORY_GAME_DIR=~/gta/game), where clearing the cache would delete the dump, or the cache/data folder from being inside it (a victory.toml kept in the dump with cache_dir = "cache"), which writes derived files and saves into the dump.
  • Config::resolve now refuses both when a game folder is set, e.g. the cache folder … (from config file) is inside the game folder … (from config file), which holds your dump and is only read; set VICTORY_CACHE_DIR or [paths].cache_dir to a folder outside it. Compared like the data-inside-cache check: lexically, ./.. folded, no disk access. Siblings (/v and /v-cache) are fine. The example file says so.
  • Tests: game_folder_is_kept_apart_from_cache_and_data, a_config_file_inside_the_dump_cannot_put_the_cache_there (synthetic paths only). On Linux cargo test -p victory-core passes 39 tests, also with HOME/XDG_* unset and with --features diagnostics (TMPDIR outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

Control characters in a path setting (config.rs)

  • A variable read from a .env file with Windows line endings (set -a; . ./victory.env, a container env file, a Proton/Wine wrapper script) ends in an invisible \r. VICTORY_GAME_DIR=/games/gta\r was then reported later only as "does not exist", which looks right on screen.
  • Every path setting (VICTORY_GAME_DIR/VICTORY_CACHE_DIR/VICTORY_DATA_DIR/VICTORY_TEST_TITLES, VICTORY_CONFIG and the [paths] values) is now checked before use. One holding a control character fails with VICTORY_GAME_DIR is "/games/gta\r", which contains the control character '\r' (a Windows line ending: was it read from a file saved with CRLF line endings?); remove it. The value is quoted so the character shows. Spaces and non-ASCII names are unaffected.
  • Test: control_characters_in_paths_are_refused (synthetic paths only). On Linux cargo test -p victory-core passes 43 tests, also with HOME/XDG_* unset and with --features diagnostics (TMPDIR outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

Quoted path settings (config.rs)

  • Only a shell strips quotes. docker run --env-file, systemd EnvironmentFile=, IDE run configurations and Windows set VICTORY_GAME_DIR="D:\games" keep them, so VICTORY_GAME_DIR="/games/gta" arrived as "/games/gta" with the quotes. That is not absolute, so it was taken as a folder named " under the working directory (often the repository) and reported later only as "does not exist" or "inside the repository".
  • Every path setting (the four variables, VICTORY_CONFIG, the [paths] values) that starts and ends with the same " or ' now fails with VICTORY_GAME_DIR is "/games/gta", quotes included; the quotes are not removed when the value comes from an env file or a launcher rather than a shell, so remove them. A quote elsewhere in a name (/games/Rockstar's) is unaffected.
  • Test: quoted_paths_are_refused (synthetic paths only). On Linux cargo test -p victory-core passes 44 tests, also with HOME/XDG_* unset and with --features diagnostics (TMPDIR outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

Whitespace around a path setting (config.rs)

  • An env file or launcher keeps the spaces a shell would split off, so VICTORY_GAME_DIR= /games/gta arrived with a leading space. That is not absolute, so it was taken as a folder named under the config file's folder or the working directory (often the repository). A trailing space (or a no-break space pasted from a web page) was reported later only as "does not exist", which looks right on screen.
  • Every path setting that starts or ends with whitespace now fails with VICTORY_GAME_DIR is " /games/gta", which starts with whitespace; remove it. VICTORY_TEST_TITLES is also checked entry by entry, so /a: /b is caught. Spaces inside a name (/Program Files/x) are unaffected.
  • Test: surrounding_whitespace_in_paths_is_refused (synthetic paths only). On Linux cargo test -p victory-core passes 45 tests, clippy -D warnings is clean for victory-core and fmt is clean.

Unexpanded variables in a path setting (config.rs, victory.example.toml)

  • Only a shell expands $HOME (and only cmd expands %LOCALAPPDATA%). TOML, docker run --env-file, systemd EnvironmentFile= and launcher or IDE run configurations keep them as written. So game_dir = "$HOME/Games/gta", or data_dir = '%LOCALAPPDATA%\victory\data' copied from the defaults the example file lists, was relative. It was taken as a folder named $HOME under the config file's folder or the working directory (often the repository).
  • Every path setting (the four variables, VICTORY_CONFIG, the [paths] values) that names a variable now fails with VICTORY_GAME_DIR is $HOME/Games/gta, which names the variable $HOME; variables are not expanded in the config file or when the value comes from an env file or a launcher rather than a shell, so write the path out in full (a leading ~ is the home directory). It recognises a whole $NAME component, ${NAME} and %NAME% (including %ProgramFiles(x86)%). Real names such as $Recycle.Bin, share$, $HOME.old and 100% are unaffected. The example file now says variables are not expanded.
  • Test: unexpanded_variables_in_paths_are_refused (synthetic paths only). On Linux cargo test -p victory-core passes 46 tests, also with HOME/XDG_* unset and with --features diagnostics (TMPDIR outside the repository). clippy -D warnings is clean for the host, with diagnostics, and for x86_64-pc-windows-msvc. fmt is clean and cargo xtask policy is ok.

Empty values in the config file (config.rs, victory.example.toml)

  • An empty variable already counted as unset, but an empty value in the file did not. game_dir = '' (a blank a template leaves to fill in) was anchored at the config file's folder, often the repository, and with ./victory.toml it became the empty path, which is the working directory. test_titles = [''] did the same for one entry.
  • Empty game_dir, cache_dir, data_dir and test_titles entries in [paths] now count as unset, so the defaults apply and victory config reports [default], not [config file]. The example file says so.
  • Test: empty_file_values_count_as_unset (synthetic paths only). On Linux cargo test -p victory-core passes 47 tests, also with HOME/XDG_* unset and with --features diagnostics (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and for x86_64-pc-windows-msvc. fmt is clean and cargo xtask policy is ok.

A folder setting that names a file (config.rs)

  • VICTORY_GAME_DIR=~/games/gta/default.xex (the executable picked in a file dialog or pasted from a launcher's target, rather than its folder) was accepted and only failed later, per file, with "Not a directory". A cache or data folder that names an existing file failed on first use with "File exists", naming neither the setting nor the fix.
  • Each of the game, cache and data folders that names an existing file now fails at load with the game folder /games/gta/default.xex (from VICTORY_GAME_DIR) is a file, not a folder; set VICTORY_GAME_DIR or [paths].game_dir to the folder holding the dump, perhaps /games/gta. A path that does not exist yet is still fine.
  • Test: a_folder_setting_naming_a_file_is_refused (an empty scratch file under the system temp folder, removed afterwards; no game data). On Linux cargo test -p victory-core passes 48 tests, also with HOME/XDG_* unset and with --features diagnostics (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and for x86_64-pc-windows-msvc. fmt is clean and cargo xtask policy is ok.

A leading ~ with no home directory (config.rs)

  • With HOME and USERPROFILE unset or relative (env -i, a bare systemd unit, some containers), a leading ~ was kept as written. VICTORY_CACHE_DIR=~/cache then named a folder literally called ~ under the working directory (often the repository), and [paths].game_dir = '~/gta' one next to the config file. Such a folder is created on first use and easy to delete by mistake with rm -rf ~.
  • A leading ~ in any path setting (the four variables, VICTORY_CONFIG, the [paths] values) now fails at load when there is no home directory: VICTORY_CACHE_DIR is ~/cache, but there is no home directory to put in place of ~ (HOME is unset or not absolute); set HOME or write the full path. ~user/…, a non-leading ~, and paths without ~ are unaffected.
  • Test: a_leading_tilde_without_a_home_is_refused (synthetic paths only); a_leading_tilde_is_the_home_directory and victory_config_expands_tilde_and_ignores_empty updated. On Linux cargo test -p victory-core passes 49 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and for x86_64-pc-windows-msvc. fmt is clean and cargo xtask policy is ok.

A file:// URI instead of a path (config.rs)

  • Copying a folder in a Linux file manager, or taking it from a .desktop file or a launcher's config, gives file:///home/me/Games/My%20Games/gta. Nothing decoded it: the value is relative, so it was taken as a folder named file: under the config file's folder or the working directory (often the repository), with %20 kept as three characters.
  • Every path setting (the four variables, VICTORY_CONFIG, the [paths] values) that starts with file: (any case) now fails at load: VICTORY_GAME_DIR is file:///games/My%20Games/gta, a file: URI rather than a path; write the path instead, perhaps /games/My Games/gta. The suggestion decodes %XX, accepts an empty or localhost host and turns /C:/games into C:/games; for another host (a network share) or a bad escape it is left out. /files, filed and file are unaffected.
  • Test: file_uris_are_refused (synthetic paths only). On Linux cargo test -p victory-core passes 50 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and for x86_64-pc-windows-msvc. fmt is clean and cargo xtask policy is ok.

Relative path settings (config.rs)

  • A relative variable such as VICTORY_DATA_DIR=data (or a relative value in ./victory.toml, whose folder is the empty path) was kept relative. The data-inside-cache and game-folder checks compare paths as written, so VICTORY_CACHE_DIR=/home/me/victory with VICTORY_DATA_DIR=data, started from /home/me/victory, put saves inside the cache unnoticed, and victory config showed data rather than the folder used.
  • Config::load now joins any path still relative after resolution to the working directory before the checks, so they see the real folder and victory config shows it. Paths in a VICTORY_CONFIG file elsewhere are still relative to that file.
  • Test: relative_paths_are_joined_to_the_working_directory (synthetic paths only). On Linux cargo test -p victory-core passes 54 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

Cache or data folder at the drive root or the home folder (config.rs)

  • VICTORY_CACHE_DIR=$HOME/$APP with APP unset is ~/, and VICTORY_DATA_DIR=$XDG_DATA_HOME/ with XDG_DATA_HOME unset is /. Both were accepted. The cache may be deleted at any time, so clearing a cache of ~ would delete the home folder, and a data folder of ~ puts saves, settings and crashes.log loose in it.
  • A cache or data folder that is the root of a drive, the home folder, or a folder holding it (/home) now fails at load: the cache folder /home/me (from VICTORY_CACHE_DIR) is your home folder; set VICTORY_CACHE_DIR or [paths].cache_dir to a folder used only by Victory, or leave it unset for the default. It is compared lexically like the other folder checks (~/games/.. counts as home), and folders inside home, siblings of it and /home/me2 are unaffected. The defaults never hit it.
  • Test: cache_or_data_at_the_root_or_home_is_refused (synthetic paths only). data_inside_the_cache_names_both_origins used the home folder as its cache, so it now uses another folder. On Linux cargo test -p victory-core passes 55 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

A misspelled path variable (config.rs)

  • VICTORY_GAMEDIR=/games/gta, VICTORY_DATA_PATH=… or a lowercase victory_cache_dir was ignored without a word, and the default was used. Saves then went to ~/.local/share/victory, not the folder the user named, and the game folder was reported as not set.
  • Config::load now checks the names in the environment first. A near miss of VICTORY_GAME_DIR/VICTORY_CACHE_DIR/VICTORY_DATA_DIR/VICTORY_TEST_TITLES/VICTORY_CONFIG fails while the real variable is unset or empty: VICTORY_GAMEDIR is set, but Victory reads VICTORY_GAME_DIR, which is not set; rename VICTORY_GAMEDIR to VICTORY_GAME_DIR. A near miss is one of these: the same letters ignoring case, _ and -; a _DIR variable with the suffix dropped or spelt _PATH/_DIRECTORY/_FOLDER; VICTORY_TEST_TITLE or VICTORY_TITLES; or VICTORY_CONFIG_FILE/_PATH. When the real variable is set, the near miss is left alone. Other VICTORY_* variables (VICTORY_LOG, VICTORY_WARP, …) are unaffected.
  • Test: misspelled_variables_are_refused (synthetic names, no process environment). On Linux cargo test -p victory-core passes 58 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

VICTORY_TEST_TITLES joined with the wrong separator (config.rs, victory.example.toml)

  • VICTORY_TEST_TITLES=/t/one;/t/two (a list copied from a Windows .bat) or /t/one,/t/two on Linux, or C:\t\one:D:\t\two on Windows, was not split, so it became one title named one;/t/two under /t. Both titles were dropped without a word, and the run reported only that the path does not exist.
  • Each entry is now checked after splitting. If a ; or , (: or , on Windows) is followed, after any spaces, by the start of another absolute path (/ or ~, or a drive path on Windows), loading fails: VICTORY_TEST_TITLES holds "/t/one;/t/two", which looks like several titles joined with ';'; on this host they are separated by ':'. A folder whose name just contains a ; or , (/games/a,b) is not affected, and neither is test_titles in the file, which is a TOML array.
  • Test: test_titles_joined_with_the_wrong_separator_are_refused covers both hosts through an on_windows parameter, using synthetic paths only. On Linux, cargo test -p victory-core passes 59 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

A Windows backslash path off Windows (config.rs)

  • VICTORY_GAME_DIR=\Games\gta, ..\games\gta or [paths].data_dir = '~\saves', copied from a Windows guide or a .bat file, has no drive letter, so the drive-path check let it through. Off Windows the backslashes are ordinary characters, so it became one relative folder named \Games\gta under the config file's folder or the working directory (often the repository), and ~\saves was reported as another user's home.
  • Every path setting (the four variables, VICTORY_CONFIG, the [paths] values) that starts with a single \, or with .\, ..\ or ~\, now fails off Windows: VICTORY_GAME_DIR is \Games\gta, which uses Windows backslashes, but this host is not Windows; write it with /, perhaps /Games/gta. A backslash later in a name (games\gta, /games/a\b), UNC paths (already refused as network paths) and anything on Windows are unaffected.
  • Test: windows_backslash_paths_are_refused_off_windows (synthetic paths only); windows_network_paths_are_refused_off_windows no longer lists \games as allowed. On Linux cargo test -p victory-core passes 60 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

Keep the test titles apart from the cache and data folders (config.rs)

  • The game folder was already kept apart from the cache and data folders, but the VICTORY_TEST_TITLES / [paths].test_titles entries, which are also dumps Victory only reads, were not. With one parent folder for everything (VICTORY_CACHE_DIR=~/xbox, VICTORY_TEST_TITLES=~/xbox/title-a), clearing the cache would delete a title, and a cache or data folder inside a title would mix derived files and saves into that dump.
  • Each title is now checked the same way: the test title /x/title-a (from VICTORY_TEST_TITLES) is inside the cache folder /x (from VICTORY_CACHE_DIR), which may be deleted at any time; ..., and the data folder ... is inside the test title .... Compared lexically like the other folder checks (./.. folded, case folded on Windows/macOS); siblings such as /x-cache are fine.
  • Test: test_titles_are_kept_apart_from_cache_and_data (synthetic paths only). On Linux cargo test -p victory-core passes 61 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

A test title that names a file (config.rs)

  • The game folder was already refused when it names a file (VICTORY_GAME_DIR=~/games/gta/default.xex), but VICTORY_TEST_TITLES / [paths].test_titles entries, which are dumps too, were not: picking the executable instead of its folder was accepted and only failed later, per file, with "Not a directory".
  • Each title is now checked the same way: the test title /x/title-a/default.xex (from VICTORY_TEST_TITLES) is a file, not a folder; set VICTORY_TEST_TITLES or [paths].test_titles to the folder holding the dump, perhaps /x/title-a. A title that does not exist yet is still accepted.
  • Test: a_folder_setting_naming_a_file_is_refused now covers a title from the variable and from the file (empty scratch file under TMPDIR, removed afterwards). On Linux cargo test -p victory-core passes 61 tests, also with HOME/XDG_* unset and with --features diagnostics. clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

A test title listed twice, or the game folder in the list (config.rs)

  • victory census, translate and shader take the game folder followed by the test titles when given no paths, so a title listed twice (VICTORY_TEST_TITLES=/x/a:/x/b:/x/a, or the same folder written as /x/a and /x/b/../a, or C:\Xbox\A and c:\xbox\a on Windows) or the game folder pasted into test_titles was scanned and translated twice, doubling the time and the report.
  • Now refused: the test title /x/a (from VICTORY_TEST_TITLES) is listed twice (also as /x/a); remove one from VICTORY_TEST_TITLES or [paths].test_titles, and the test title /x/a (from config file) is the game folder /x/a (from VICTORY_GAME_DIR); .... Compared lexically like the other folder checks (case folded on Windows/macOS only). A title nested inside another title or inside the game folder is a different folder and is still accepted.
  • Test: test_titles_must_be_distinct_and_not_the_game_folder (synthetic paths only); a_folder_setting_naming_a_file_is_refused no longer lists the game folder as a title. On Linux cargo test -p victory-core passes 62 tests, also with HOME/XDG_* unset (TMPDIR and the build folder outside the repository). clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

A data folder inside the user's cache (config.rs)

  • The data folder was only kept out of Victory's own cache folder, so VICTORY_DATA_DIR=~/.cache/victory-saves, or XDG_DATA_HOME set under XDG_CACHE_HOME (~/.cache/share, which moves the default data folder there while the cache folder is a sibling), was accepted, and clearing ~/.cache (the problem this PR started from) deleted the saves.
  • Now refused: the data folder /home/me/.cache/saves (from VICTORY_DATA_DIR) is inside your cache folder /home/me/.cache (~/.cache), which may be deleted at any time; set VICTORY_DATA_DIR or [paths].data_dir to a folder outside it, such as one under ~/.local/share, with a variant naming XDG_DATA_HOME when both are defaults. The cache base is $XDG_CACHE_HOME (absolute), else $HOME/.cache; the check is skipped when that base is the home folder or holds it. Compared lexically like the other folder checks.
  • Test: data_inside_the_user_cache_is_refused (synthetic paths only). On Linux cargo test -p victory-core passes 63 tests, also with HOME/XDG_* unset. clippy -D warnings is clean for the host and x86_64-pc-windows-msvc, fmt is clean and cargo xtask policy is ok.

A trailing slash or /. no longer hides a file or a dead link in a folder setting
lstat("link/") follows the link, and Path::ancestors goes from default.xex/ straight to its parent. So VICTORY_GAME_DIR=…/default.xex/, or a cache, data or test-title setting naming a dangling or looping link with a trailing / or /., was accepted as a folder still to create. It then failed later with "Not a directory" or "File exists". The folder check now walks the path with trailing separators and interior . dropped (.. is kept), and the setting is still stored as written. Test: a_trailing_slash_or_dot_does_not_hide_a_file_or_a_link_that_leads_nowhere (Unix, scratch folder under the temp dir). I confirmed it fails without the fix.

Supersedes #243, #277 and #266.

AI-assisted (Claude Code).

SkippySteve added 3 commits November 23, 2026 20:43
Without LOCALAPPDATA the default data dir was $XDG_CACHE_HOME/victory/data,
so clearing the user's cache deleted what titles saved, which the doc on
Config::data_dir says must never be inside the cache. Use $XDG_DATA_HOME
(~/.local/share) for data and $XDG_CACHE_HOME (~/.cache) for the cache,
ignore empty or relative XDG values as the spec says, and read them through
the same env lookup as the rest of resolve() so the defaults are testable.
XDG_CACHE_HOME= (set but empty), or a relative LOCALAPPDATA, XDG_CACHE_HOME
or HOME, made the default cache and data directories relative to the working
directory, usually the repository, where the asset policy then refuses them.
Such values are now skipped, as the XDG base directory spec asks.

The default directories are now read through the same environment closure as
the rest of Config::resolve, so its tests no longer depend on the host's
LOCALAPPDATA/XDG_CACHE_HOME/HOME.
@SkippySteve

Copy link
Copy Markdown
Author

I've merged #243 (skip empty or relative LOCALAPPDATA/XDG/HOME values, hermetic tests) into this branch, since both PRs changed the same function. I've closed #243 so only one PR changes config.rs. cargo test -p victory-core passes (13 tests) and clippy is clean with -D warnings (host and Windows MSVC).

…the repo

The data folder (saves, settings, crashes.log) is resolved by Config
like the cache folder, but `victory config` neither printed it nor ran
the outside-the-repository check on it, so a VICTORY_DATA_DIR or
[paths].data_dir pointing into the source tree went unreported.
A filter that tracing-subscriber rejects, such as VICTORY_LOG=victory_loader=loud,
was dropped without a word and the binary logged at its default level, so a
typo looked like the target had nothing to say. init now prints one line on
stderr naming the variable, its value and the parse error, then uses the
default as before.

Choosing the filter moves into choose_filter so it can be tested without
touching the process environment; five unit tests cover unset, VICTORY_LOG
over RUST_LOG, the RUST_LOG fallback, and a bad value in each variable.
@SkippySteve SkippySteve changed the title Config: off Windows, keep the default data dir out of the XDG cache Core host UX: XDG data dir off Windows, and warn on a bad VICTORY_LOG/RUST_LOG Nov 24, 2026
SkippySteve added 2 commits November 23, 2026 21:39
…ICTORY_CONFIG/VICTORY_TEST_TITLES

With VICTORY_CONFIG pointing at another directory, a relative
cache_dir/data_dir/game_dir/test_titles entry resolved against the working
directory (often the repository, which the asset policy then refuses).
They are now relative to the config file. An empty VICTORY_CONFIG no
longer fails with 'points at , which does not exist', and an empty
VICTORY_TEST_TITLES no longer wipes the file's list, matching how the
other VICTORY_* variables already treat empty values.
…ld caps the filter

An empty VICTORY_LOG= produced an empty filter that hid everything but
errors and shadowed RUST_LOG. And VICTORY_LOG=trace on a build without
the diagnostics feature was silently capped at info, which looked like
the code had nothing to log; it now says so on stderr.
@SkippySteve SkippySteve changed the title Core host UX: XDG data dir off Windows, and warn on a bad VICTORY_LOG/RUST_LOG Core host UX: XDG data dir, config-relative paths, and clearer VICTORY_LOG handling Nov 24, 2026
SkippySteve added 4 commits November 23, 2026 21:47
Neither TOML nor a quoted shell value expands ~, so game_dir = "~/games"
in victory.toml named a folder called ~ next to the file, and a quoted
VICTORY_GAME_DIR="~/games" one under the working directory. A leading ~
component in [paths] values and the VICTORY_*_DIR / VICTORY_TEST_TITLES
variables now means HOME (else USERPROFILE), when that is absolute.
~user and paths with no usable home directory are left as written.
… is not UTF-8; document the Linux defaults

VICTORY_CONFIG pointing at the folder that holds victory.toml was reported as
'does not exist'. It now says it is a folder and, when victory.toml is inside,
names it. A VICTORY_LOG/RUST_LOG value that is not valid UTF-8 was dropped
silently; it is now reported on stderr and treated as unset.
victory.example.toml gives the XDG defaults used without LOCALAPPDATA.

AI-assisted (Claude Code).
Config::data_dir is documented as never inside the cache, which may be
deleted at any time, but explicit settings such as
VICTORY_CACHE_DIR=~/victory with VICTORY_DATA_DIR=~/victory/data, or a
cache set to ~ with the default data dir, put saves under the cache.
Config::resolve now reports that with the two paths. The tilde test now
uses ~/cache, since a cache of ~ would hold the default data folder.
… other path variables

AI-assisted (Claude Code).
@SkippySteve SkippySteve mentioned this pull request Nov 24, 2026
2 of 3 tasks
SkippySteve added 2 commits November 23, 2026 22:13
…and the data-inside-cache error

Config gains `origins` (env variable, config file, or default) for game_dir,
cache_dir, data_dir and test_titles. `victory config` prints it next to each
value, and the data-inside-cache error says which setting each folder came
from, so a refused default data folder under a file-set cache points at the
right line. Empty variables still count as unset and are not the origin.

AI-assisted (Claude Code).
On Linux 'D:\victory-data\game' is not absolute, so the example config's
game_dir copied unedited became a folder under the config file's directory
(the repository), reported later as a policy violation or a missing
folder. The file's [paths] values and the VICTORY_* path variables are now
checked first, and the error names the setting.

AI-assisted (Claude Code).
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
… clearer VICTORY_LOG handling

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SkippySteve added 7 commits November 23, 2026 22:33
…cache

~/.cache/victory/../data is a sibling of the cache but was refused, and a
cache of ~/victory/tmp/.. was not seen to hold ~/victory/data. Compare the
paths with . and .. folded lexically (still without touching the disk).
The game folder inside the cache would be deleted with it, and a cache or
data folder inside the game folder writes into the user's dump (easy with a
victory.toml kept in the dump and cache_dir = "cache"). Config::resolve now
refuses both, naming where each folder came from; compared lexically like
the data-inside-cache check.
…v's trailing \r)

A variable read from a .env file with Windows line endings ends in an
invisible \r, so the path was later reported only as "does not exist".
Every path setting (VICTORY_*_DIR, VICTORY_TEST_TITLES, VICTORY_CONFIG,
[paths]) is now checked first and the error quotes the value.
…s/gta" kept literally)

docker --env-file, systemd EnvironmentFile=, IDE run configurations and
Windows `set X="..."` keep the quotes as part of the value. The path then
starts with a quote, is not absolute, and lands under the working
directory, reported later only as "does not exist". Every path setting
now fails with an error naming it. A quote elsewhere in a name is fine.
SkippySteve added 20 commits November 24, 2026 04:51
… that leads nowhere is an error naming it; a link to a folder is used as is
…ed with a trailing slash is refused by kind before it is opened
…g; a config link with a relative target is followed from its folder and named as written
…er is an error naming it, returned without blocking, and left as it was
…named byte for byte; a file or dangling link under such a name is refused by kind
…d and named the lossy way; VICTORY_CONFIG under a folder link is read where it leads; stray bytes are located on short, truncated and CRLF text
…written, so the missing name is the last one shown
…t leads, as the OS does, so a gone end is named, never a decoy beside the link
… or `/.` says to drop it from the link, naming the hops and the file, rather than "Not a directory"
…, `mid/.`) is followed past it, so a gone end is named rather than the slashed link that is present
…ocket or device as if it were a folder names it by kind alongside "Not a directory", rather than the bare OS error
… loops back to, rather than the bare "Too many levels of symbolic links"
…on names that folder and the setting, rather than passing as a folder still to create and failing with "Permission denied" on first use
…m allows names the name, its length and the folder it would be made in, rather than passing as a folder still to create and failing with "File name too long" on first use
…hole path is longer than the system takes names its length and the deepest folder that is there, rather than passing as a folder still to create and failing with "File name too long" on first use
… or under a folder without search permission, names that, rather than calling the link one whose target was moved, deleted or loops
… are followed (data under a link into the cache, or a cache that is a link to the folder holding the data) is refused, naming where each one is on disk, rather than passing the lexical check and going with the cache when it is emptied
…e links are followed (a dump reached through a link into the cache, or a cache or data folder under a link into the dump) is refused, naming where each one is on disk, rather than passing the lexical check and going with the cache when it is emptied
…ce links are followed (a link to the dump, or a title reached through a link to its folder) is refused, naming where both are on disk, rather than passing the lexical check and being scanned and translated twice
@MichaelSmithAI

Copy link
Copy Markdown

One upgrade detail for native Linux users: with a marker in the former default ~/.cache/victory/data, the CLI selects the new XDG data directory and leaves the marker behind. Pointing VICTORY_DATA_DIR back into the cache is rejected, as intended. An ordinary Wine prefix continued to use its existing AppData paths.

A short migration note beside the new defaults would help people find existing saves: before clearing the cache, check the former data directory ($XDG_CACHE_HOME/victory/data, normally ~/.cache/victory/data). If it contains data to keep, back it up, run victory config to find the new data_dir, and copy the contents there, preserving any newer files. The CLI check used synthetic data.

SkippySteve and others added 4 commits November 24, 2026 06:16
…s up or at the end of a link, names that folder and VICTORY_CONFIG, rather than a bare "Permission denied" under the file's own name
…e that is relative to it, naming that value, its setting and what to change, rather than refusing to start with "reading the working directory: No such file or directory" when every path is absolute
…owed (a saves folder reached through a link next to the dump) is refused, naming where each one is on disk, rather than passing the lexical check and writing into the dump

Co-authored-by: Cursor <cursoragent@cursor.com>
… links are followed

Data-inside-game was already link-aware; the opposite placements (a dump under saves, or reached only through a symlink next to the data root) still passed the lexical check and would mix read-only dumps with persistent saves.

Co-authored-by: Cursor <cursoragent@cursor.com>
@alexdeliu

Copy link
Copy Markdown

Merged onto main @ ffe310eb (PR head e8fbe936), this does not build on Windows: the tests in crates/victory-core/src/config.rs (around lines 7568-7612) use std::os::unix::{fs::symlink, fs::FileTypeExt, net::UnixListener} without #[cfg(unix)], so cargo clippy --all-targets fails with E0433: cannot find unix in os and E0599: no method is_socket. Gating those tests on #[cfg(unix)] should be enough.

Checked with CI's steps (both clippy runs with -D warnings, cargo test --workspace) on Windows 11, AMD RX 9070. Every open PR: https://gist.github.com/alexdeliu/ef9ef0ebc1776ff104b5aa8eaea18e87

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: apps/victory/src/main.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

@SkippySteve SkippySteve closed this by deleting the head repository Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants