fix(config): use canonical XDG path for default config (#741)#904
Open
ChrisJr404 wants to merge 1 commit intobee-san:masterfrom
Open
fix(config): use canonical XDG path for default config (#741)#904ChrisJr404 wants to merge 1 commit intobee-san:masterfrom
ChrisJr404 wants to merge 1 commit intobee-san:masterfrom
Conversation
…toml (bee-san#741) The XDG support added in 2020 was rewritten at some point into dirs::config_dir().push(".rustscan.toml") which produces `~/.config/.rustscan.toml` on Linux — a leading-dot filename inside the already-hidden `.config` directory, which isn't the form the spec recommends (and isn't the form mulc's original commit a0561d4 introduced). This restores the canonical `$XDG_CONFIG_HOME/rustscan/config.toml` path as the primary config location while preserving full backwards compatibility: the loader now searches, in order, 1. $XDG_CONFIG_HOME/rustscan/config.toml (preferred, XDG-idiomatic) 2. $XDG_CONFIG_HOME/.rustscan.toml (transitional) 3. ~/.rustscan.toml (legacy) so any user who already adopted the leading-dot form keeps working unchanged, and `~/.rustscan.toml` continues to be honoured. Closes bee-san#741.
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.
Closes #741.
Background
The XDG support originally added to RustScan in 2020 (commit a0561d4 by @mulc) was structured as
$XDG_CONFIG_HOME/rustscan/config.toml. At some point that was refactored intowhich on Linux resolves to
~/.config/.rustscan.toml— a leading-dot filename inside the already-hidden.config/directory. That isn't the form the XDG Base Directory Specification recommends, and it isn't the form mulc's commit introduced.Change
Restore the canonical
$XDG_CONFIG_HOME/rustscan/config.tomlpath as the primary config location, while preserving full backwards compatibility for both legacy paths.The loader now searches, in this order:
$XDG_CONFIG_HOME/rustscan/config.toml— preferred, XDG-idiomatic$XDG_CONFIG_HOME/.rustscan.toml— transitional, kept for users who already adopted it~/.rustscan.toml— legacyAny user who already has a working config file in path 2 or 3 keeps working unchanged.
On macOS this maps to
~/Library/Application Support/rustscan/config.toml, on Windows to{FOLDERID_RoamingAppData}/rustscan/config.toml— both via the existingdirs::config_dir()crate. The Linux behavior is what users in the issue thread are asking for; the macOS/Windows behavior was already happening because ofdirs::config_dir().Verification
cargo test --libpasses (50 tests, including the existing config tests).Diff is
+25 / -5lines, single file, no public-API change beyond adding the newlegacy_dot_config_path()helper.