Repository navigation
Core host UX: XDG data dir, config-relative paths, and clearer VICTORY_LOG handling - #241
SkippySteve wants to merge 97 commits into
Conversation
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.
|
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 |
…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.
…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.
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).
…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).
… clearer VICTORY_LOG handling Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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.
…annot leave its root
…ME when both defaults collide
…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.
… env file's ' /games/gta')
… 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
|
One upgrade detail for native Linux users: with a marker in the former default A short migration note beside the new defaults would help people find existing saves: before clearing the cache, check the former data directory ( |
…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>
|
Merged onto Checked with CI's steps (both clippy runs with |
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
Host-side UX fixes in
victory-corefor where Victory keeps files and how it reports its settings. This PR now also includes #243, which changed the same function, #277, which makesvictory configshow the data folder, and #266, which warns whenVICTORY_LOG/RUST_LOGdoes not parse. #243, #277 and #266 are closed in its favour.Problem
Config::data_diris documented as "never inside the cache, which may be deleted at any time". WithoutLOCALAPPDATA(a native non-Windows host, e.g. the Linux crates/tools),default_dirused 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.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, andcache_subdirfailed with the asset-policy error instead of using~/.cache.Change (
crates/victory-core/src/config.rsonly)LOCALAPPDATA: unchanged (…\victory\cache,…\victory\data).$XDG_CACHE_HOME/victory(else~/.cache/victory), data →$XDG_DATA_HOME/victory(else~/.local/share/victory).LOCALAPPDATA/XDG_CACHE_HOME/XDG_DATA_HOME/HOMEvalues 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_dirnow reads through the sameenvclosure thatConfig::resolvealready takes, so the defaults can be unit-tested.load()still passes the real environment.VICTORY_CACHE_DIR/VICTORY_DATA_DIRandvictory.tomlstill take precedence.Tests (hermetic: none read the host's real
HOME/XDG_*/LOCALAPPDATA, and they useC:\…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.resolvetests now getHOMEthrough the closure. Before, they failed underenv -u HOME.Validated on Linux (config part):
cargo test -p victory-corepasses, and also passes withHOME,XDG_CACHE_HOMEandXDG_DATA_HOMEunset.cargo clippy -p victory-core --all-targets -- -D warningsis clean for the host and forx86_64-pc-windows-msvc.config.rspasses rustfmt, andcargo xtask policyis ok. I haven't run it on Windows. No game data was used.victory configshows the data folder (was #277,apps/victory/src/main.rs)The data folder (saves, settings, crashes.log) is resolved by
Configlike the cache folder, butvictory configneither printed it nor ran the outside-the-repository check on it, so aVICTORY_DATA_DIRor[paths].data_dirpointing into the source tree went unreported. It now printsdata_dirand checks it withensure_outside_repoalongsidecache_dir. Two lines;apps/victorydoes not yet build on Linux (#235), so this part is checked by review only.Warn when
VICTORY_LOG/RUST_LOGdoes 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::initnow prints one line on stderr naming the variable, its value and the parse error, then falls back to the default level as before:Picking the filter moves into
choose_filter, so it can be tested without changing the process environment. Precedence is unchanged (VICTORY_LOG, thenRUST_LOG, then the default). Five new tests: unset,VICTORY_LOGoverRUST_LOG, theRUST_LOGfallback, and a bad value in each variable.Config file paths and empty variables (
config.rs,victory.example.toml)game_dir,cache_dir,data_dir,test_titles) are now relative to the file. Before, withVICTORY_CONFIGpointing at another folder,cache_dir = "cache"landed under the working directory, which is often the repository, so the asset policy refused it../victory.tomlbehaves as before.VICTORY_CONFIGcounts as unset instead of failing with "points at , which does not exist". An emptyVICTORY_TEST_TITLESno longer replaces the file's list with nothing. The otherVICTORY_*variables already ignored empty values.victory.example.tomlsays this and gives the rightVICTORY_TEST_TITLESseparator (;on Windows,:elsewhere).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
diagnosticscap (logging.rs)VICTORY_LOG/RUST_LOGcounts as unset. Before,VICTORY_LOG=made an empty filter that hid everything but errors and also hidRUST_LOG.diagnosticsfeature 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.empty_values_count_as_unset,a_filter_above_the_cap_is_reported.~in configured paths (config.rs,victory.example.toml)~. Sogame_dir = "~/Games/gta"invictory.tomlnamed a folder literally called~next to the file, andVICTORY_GAME_DIR="~/Games/gta"named one under the working directory. That's an easy mistake on Linux/Proton setups.~component in[paths]values and inVICTORY_GAME_DIR/VICTORY_CACHE_DIR/VICTORY_DATA_DIR/VICTORY_TEST_TITLESnow means the home directory:HOME, elseUSERPROFILE, 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).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_CONFIGas a folder, non-UTF-8 log variables, Linux defaults (config.rs,logging.rs,victory.example.toml)VICTORY_CONFIGpointing at the folder that holdsvictory.tomlwas 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 intoconfig_fileso it can be tested.VICTORY_LOG/RUST_LOGvalue that is not valid UTF-8 was dropped silently bystd::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.tomlgave only the%LOCALAPPDATA%defaults. It now also gives the Linux ones ($XDG_CACHE_HOME/victoryor~/.cache/victory,$XDG_DATA_HOME/victoryor~/.local/share/victory) and saysVICTORY_CONFIGnames the file, not its folder.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_diris documented as never inside the cache, but explicit settings could still put it there, e.g.VICTORY_CACHE_DIR=~/victorywithVICTORY_DATA_DIR=~/victory/data, orVICTORY_CACHE_DIR=~with the default~/.local/share/victory. Clearing the cache would then delete saves.Config::resolvenow fails withthe 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-datanext to/vis allowed, and so is the cache inside the data folder.data_inside_the_cache_is_refused.tilde_in_variables_is_homenow sets the cache to~/cache, because a cache of~would hold the default data folder.~inVICTORY_CONFIG(config.rs,victory.example.toml)~, butVICTORY_CONFIGdid not, so a quotedVICTORY_CONFIG="~/victory.toml"failed withVICTORY_CONFIG points at ~/victory.toml, which does not exist. It now goes through the sameexpand_home(via a smallexplicit_confighelper, so it can be tested without touching the real environment); empty still counts as unset.load()resolves the home directory once and reuses it.victory_config_expands_tilde_and_ignores_empty. This also covers what open Config: ignore an empty VICTORY_CONFIG #363 asks for (emptyVICTORY_CONFIG), which this PR already did.Validated (whole PR) on Linux:
cargo test -p victory-corepasses (33 tests), also withHOME/XDG_CACHE_HOME/XDG_DATA_HOMEunset and with--features diagnostics.cargo clippy -p victory-core --all-targets -- -D warningsis clean with and without--features diagnostics, and forx86_64-pc-windows-msvc.cargo fmt -p victory-core --checkis clean andcargo xtask policyis ok.Say where each setting came from (
config.rs,apps/victory/src/main.rs)Confignow hasorigins(Origin::Env("VICTORY_CACHE_DIR"),Origin::FileorOrigin::Default) forgame_dir,cache_dir,data_dirandtest_titles. Empty variables still count as unset and are never the origin.victory configprints it next to each value, e.g.cache_dir : /home/me/.cache/victory [default].the data folder … (from default) is inside the cache folder … (from config file) ….origins_name_the_setting_that_won,data_inside_the_cache_names_both_origins. With them,cargo test -p victory-corepasses 33 tests (also withHOME/XDG_*unset and with--features diagnostics). clippy-D warningsis clean for the host, withdiagnostics, and forx86_64-pc-windows-msvc. fmt is clean andcargo xtask policyis ok. As before, themain.rslines 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.tomlshipsgame_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 andVICTORY_GAME_DIR/VICTORY_CACHE_DIR/VICTORY_DATA_DIR/VICTORY_TEST_TITLESare now checked before use. On a non-Windows host,X:,X:\…orX:/…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_TITLESis checked before it is split, because:would cutD:\ain two. Windows is unchanged. The example file now says its paths are Windows examples.windows_drive_paths_are_refused_off_windows. On Linuxcargo test -p victory-corepasses 34 tests, also withHOME/XDG_*unset and with--features diagnostics. clippy-D warningsis clean for the host, withdiagnostics, and forx86_64-pc-windows-msvc. fmt is clean andcargo xtask policyis ok.A
[paths]key at the top level of the config file (config.rs)game_dir = '/games/gta'with no[paths]header (an easy firstvictory.toml), or a key written above the header, failed with onlyunknown field \game_dir`, expected `paths`. It now saysgame_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.top_level_path_keys_say_where_they_belong;example_config_parsesgoes through the same parser. On Linuxcargo test -p victory-corepasses 35 tests, also withHOME/XDG_*unset and with--features diagnostics. clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok..and..in the data/cache check (config.rs)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.data_inside_the_cache_ignores_dot_dot,lexical_folds_dot_and_dot_dot. On Linuxcargo test -p victory-corepasses 37 tests, also withHOME/XDG_*unset and with--features diagnostics(run withTMPDIRoutside the repository, whichpolicy::tests::accepts_unrelated_directoriesneeds). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.Keep the game folder apart from the cache and data folders (
config.rs,victory.example.toml)VICTORY_CACHE_DIR=~/gtawithVICTORY_GAME_DIR=~/gta/game), where clearing the cache would delete the dump, or the cache/data folder from being inside it (avictory.tomlkept in the dump withcache_dir = "cache"), which writes derived files and saves into the dump.Config::resolvenow 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 (/vand/v-cache) are fine. The example file says so.game_folder_is_kept_apart_from_cache_and_data,a_config_file_inside_the_dump_cannot_put_the_cache_there(synthetic paths only). On Linuxcargo test -p victory-corepasses 39 tests, also withHOME/XDG_*unset and with--features diagnostics(TMPDIRoutside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.Control characters in a path setting (
config.rs).envfile 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\rwas then reported later only as "does not exist", which looks right on screen.VICTORY_GAME_DIR/VICTORY_CACHE_DIR/VICTORY_DATA_DIR/VICTORY_TEST_TITLES,VICTORY_CONFIGand the[paths]values) is now checked before use. One holding a control character fails withVICTORY_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.control_characters_in_paths_are_refused(synthetic paths only). On Linuxcargo test -p victory-corepasses 43 tests, also withHOME/XDG_*unset and with--features diagnostics(TMPDIRoutside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.Quoted path settings (
config.rs)docker run --env-file, systemdEnvironmentFile=, IDE run configurations and Windowsset VICTORY_GAME_DIR="D:\games"keep them, soVICTORY_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".VICTORY_CONFIG, the[paths]values) that starts and ends with the same"or'now fails withVICTORY_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.quoted_paths_are_refused(synthetic paths only). On Linuxcargo test -p victory-corepasses 44 tests, also withHOME/XDG_*unset and with--features diagnostics(TMPDIRoutside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.Whitespace around a path setting (
config.rs)VICTORY_GAME_DIR= /games/gtaarrived with a leading space. That is not absolute, so it was taken as a folder namedunder 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.VICTORY_GAME_DIR is " /games/gta", which starts with whitespace; remove it.VICTORY_TEST_TITLESis also checked entry by entry, so/a: /bis caught. Spaces inside a name (/Program Files/x) are unaffected.surrounding_whitespace_in_paths_is_refused(synthetic paths only). On Linuxcargo test -p victory-corepasses 45 tests, clippy-D warningsis clean for victory-core and fmt is clean.Unexpanded variables in a path setting (
config.rs,victory.example.toml)$HOME(and onlycmdexpands%LOCALAPPDATA%). TOML,docker run --env-file, systemdEnvironmentFile=and launcher or IDE run configurations keep them as written. Sogame_dir = "$HOME/Games/gta", ordata_dir = '%LOCALAPPDATA%\victory\data'copied from the defaults the example file lists, was relative. It was taken as a folder named$HOMEunder the config file's folder or the working directory (often the repository).VICTORY_CONFIG, the[paths]values) that names a variable now fails withVICTORY_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$NAMEcomponent,${NAME}and%NAME%(including%ProgramFiles(x86)%). Real names such as$Recycle.Bin,share$,$HOME.oldand100%are unaffected. The example file now says variables are not expanded.unexpanded_variables_in_paths_are_refused(synthetic paths only). On Linuxcargo test -p victory-corepasses 46 tests, also withHOME/XDG_*unset and with--features diagnostics(TMPDIRoutside the repository). clippy-D warningsis clean for the host, withdiagnostics, and forx86_64-pc-windows-msvc. fmt is clean andcargo xtask policyis ok.Empty values in the config file (
config.rs,victory.example.toml)game_dir = ''(a blank a template leaves to fill in) was anchored at the config file's folder, often the repository, and with./victory.tomlit became the empty path, which is the working directory.test_titles = ['']did the same for one entry.game_dir,cache_dir,data_dirandtest_titlesentries in[paths]now count as unset, so the defaults apply andvictory configreports[default], not[config file]. The example file says so.empty_file_values_count_as_unset(synthetic paths only). On Linuxcargo test -p victory-corepasses 47 tests, also withHOME/XDG_*unset and with--features diagnostics(TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host and forx86_64-pc-windows-msvc. fmt is clean andcargo xtask policyis 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.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.a_folder_setting_naming_a_file_is_refused(an empty scratch file under the system temp folder, removed afterwards; no game data). On Linuxcargo test -p victory-corepasses 48 tests, also withHOME/XDG_*unset and with--features diagnostics(TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host and forx86_64-pc-windows-msvc. fmt is clean andcargo xtask policyis ok.A leading
~with no home directory (config.rs)HOMEandUSERPROFILEunset or relative (env -i, a bare systemd unit, some containers), a leading~was kept as written.VICTORY_CACHE_DIR=~/cachethen 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 withrm -rf ~.~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.a_leading_tilde_without_a_home_is_refused(synthetic paths only);a_leading_tilde_is_the_home_directoryandvictory_config_expands_tilde_and_ignores_emptyupdated. On Linuxcargo test -p victory-corepasses 49 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host and forx86_64-pc-windows-msvc. fmt is clean andcargo xtask policyis ok.A
file://URI instead of a path (config.rs).desktopfile or a launcher's config, givesfile:///home/me/Games/My%20Games/gta. Nothing decoded it: the value is relative, so it was taken as a folder namedfile:under the config file's folder or the working directory (often the repository), with%20kept as three characters.VICTORY_CONFIG, the[paths]values) that starts withfile:(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 orlocalhosthost and turns/C:/gamesintoC:/games; for another host (a network share) or a bad escape it is left out./files,filedandfileare unaffected.file_uris_are_refused(synthetic paths only). On Linuxcargo test -p victory-corepasses 50 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host and forx86_64-pc-windows-msvc. fmt is clean andcargo xtask policyis ok.Relative path settings (
config.rs)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, soVICTORY_CACHE_DIR=/home/me/victorywithVICTORY_DATA_DIR=data, started from/home/me/victory, put saves inside the cache unnoticed, andvictory configshoweddatarather than the folder used.Config::loadnow joins any path still relative after resolution to the working directory before the checks, so they see the real folder andvictory configshows it. Paths in aVICTORY_CONFIGfile elsewhere are still relative to that file.relative_paths_are_joined_to_the_working_directory(synthetic paths only). On Linuxcargo test -p victory-corepasses 54 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.Cache or data folder at the drive root or the home folder (
config.rs)VICTORY_CACHE_DIR=$HOME/$APPwithAPPunset is~/, andVICTORY_DATA_DIR=$XDG_DATA_HOME/withXDG_DATA_HOMEunset 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./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/me2are unaffected. The defaults never hit it.cache_or_data_at_the_root_or_home_is_refused(synthetic paths only).data_inside_the_cache_names_both_originsused the home folder as its cache, so it now uses another folder. On Linuxcargo test -p victory-corepasses 55 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.A misspelled path variable (
config.rs)VICTORY_GAMEDIR=/games/gta,VICTORY_DATA_PATH=…or a lowercasevictory_cache_dirwas 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::loadnow checks the names in the environment first. A near miss ofVICTORY_GAME_DIR/VICTORY_CACHE_DIR/VICTORY_DATA_DIR/VICTORY_TEST_TITLES/VICTORY_CONFIGfails 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_DIRvariable with the suffix dropped or spelt_PATH/_DIRECTORY/_FOLDER;VICTORY_TEST_TITLEorVICTORY_TITLES; orVICTORY_CONFIG_FILE/_PATH. When the real variable is set, the near miss is left alone. OtherVICTORY_*variables (VICTORY_LOG,VICTORY_WARP, …) are unaffected.misspelled_variables_are_refused(synthetic names, no process environment). On Linuxcargo test -p victory-corepasses 58 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.VICTORY_TEST_TITLESjoined 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/twoon Linux, orC:\t\one:D:\t\twoon Windows, was not split, so it became one title namedone;/t/twounder/t. Both titles were dropped without a word, and the run reported only that the path does not exist.;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 istest_titlesin the file, which is a TOML array.test_titles_joined_with_the_wrong_separator_are_refusedcovers both hosts through anon_windowsparameter, using synthetic paths only. On Linux,cargo test -p victory-corepasses 59 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.A Windows backslash path off Windows (
config.rs)VICTORY_GAME_DIR=\Games\gta,..\games\gtaor[paths].data_dir = '~\saves', copied from a Windows guide or a.batfile, 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\gtaunder the config file's folder or the working directory (often the repository), and~\saveswas reported as another user's home.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.windows_backslash_paths_are_refused_off_windows(synthetic paths only);windows_network_paths_are_refused_off_windowsno longer lists\gamesas allowed. On Linuxcargo test -p victory-corepasses 60 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.Keep the test titles apart from the cache and data folders (
config.rs)VICTORY_TEST_TITLES/[paths].test_titlesentries, 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.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; ..., andthe data folder ... is inside the test title .... Compared lexically like the other folder checks (./..folded, case folded on Windows/macOS); siblings such as/x-cacheare fine.test_titles_are_kept_apart_from_cache_and_data(synthetic paths only). On Linuxcargo test -p victory-corepasses 61 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.A test title that names a file (
config.rs)VICTORY_GAME_DIR=~/games/gta/default.xex), butVICTORY_TEST_TITLES/[paths].test_titlesentries, 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".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.a_folder_setting_naming_a_file_is_refusednow covers a title from the variable and from the file (empty scratch file underTMPDIR, removed afterwards). On Linuxcargo test -p victory-corepasses 61 tests, also withHOME/XDG_*unset and with--features diagnostics. clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.A test title listed twice, or the game folder in the list (
config.rs)victory census,translateandshadertake 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/aand/x/b/../a, orC:\Xbox\Aandc:\xbox\aon Windows) or the game folder pasted intotest_titleswas scanned and translated twice, doubling the time and the report.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, andthe 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_titles_must_be_distinct_and_not_the_game_folder(synthetic paths only);a_folder_setting_naming_a_file_is_refusedno longer lists the game folder as a title. On Linuxcargo test -p victory-corepasses 62 tests, also withHOME/XDG_*unset (TMPDIRand the build folder outside the repository). clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.A data folder inside the user's cache (
config.rs)VICTORY_DATA_DIR=~/.cache/victory-saves, orXDG_DATA_HOMEset underXDG_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.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 namingXDG_DATA_HOMEwhen 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.data_inside_the_user_cache_is_refused(synthetic paths only). On Linuxcargo test -p victory-corepasses 63 tests, also withHOME/XDG_*unset. clippy-D warningsis clean for the host andx86_64-pc-windows-msvc, fmt is clean andcargo xtask policyis ok.A trailing slash or
/.no longer hides a file or a dead link in a folder settinglstat("link/")follows the link, andPath::ancestorsgoes fromdefault.xex/straight to its parent. SoVICTORY_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).