Repository navigation
Config: skip an empty or relative cache base for the default directories - #243
Closed
SkippySteve wants to merge 1 commit into
Closed
SkippySteve wants to merge 1 commit into
SkippySteve wants to merge 1 commit into
Conversation
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.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When neither
VICTORY_CACHE_DIR/VICTORY_DATA_DIRnor the config file sets a path,Configfalls back toLOCALAPPDATA, thenXDG_CACHE_HOME, thenHOME/.cache. Today a variable that is set but empty (XDG_CACHE_HOME=, common in Linux shells and wrapper scripts) or relative wins anyway. The base then becomesvictory/cacherelative to the working directory, which is usually the repository checkout, andcache_subdirfails with the asset-policy error rather than using~/.cache.Change (
crates/victory-core/src/config.rs)default_dirskips empty and relative values, as the XDG base directory spec asks, and falls through to the next candidate. 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. Production still passesstd::env::var_os, so behaviour with sane values is unchanged.Tests
resolvetaking its defaults from the given environment.resolvetests used to depend on the host's realLOCALAPPDATA/XDG_CACHE_HOME/HOME(they failed withenv -u HOME). They now supplyHOMEthrough the closure, so they are hermetic.Validated on Linux:
cargo test -p victory-core(11 passed, also withHOMEandXDG_CACHE_HOMEunset),cargo clippy -p victory-core --all-targets -D warningsfor both the host andx86_64-pc-windows-msvc,cargo fmt --check,cargo xtask policy. I haven't run the tests on Windows. The test helper usesC:\…paths there so they are absolute.