fix(maa-dirs): treat empty directory environment variables as unset#563
Open
JIAFALSEDREAM wants to merge 1 commit into
Open
fix(maa-dirs): treat empty directory environment variables as unset#563JIAFALSEDREAM wants to merge 1 commit into
JIAFALSEDREAM wants to merge 1 commit into
Conversation
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.
问题描述
dir_from_env当前会将值为空的环境变量视为有效路径。例如:
此时数据目录和缓存目录都可能被解析为相对路径
maa/:这会导致 MaaCore 的基础资源目录与热更新缓存目录重合。热更新下载的
tasks.json增量资源可能因此覆盖基础资源中的完整tasks.json,最终导致资源加载失败。根据 XDG Base Directory Specification,XDG 环境变量未设置或值为空时,都应回退到默认目录。
修改内容
MAA_*_DIR环境变量,并继续尝试对应的 XDG 环境变量。XDG_*_HOME环境变量,并回退到平台默认目录。MAA_*_DIR优先于 XDG 环境变量的现有行为。测试结果
cargo test -p maa-dirscargo clippy --workspace --all-targetscargo x test~/.local/share/maa,而不是相对路径maa/Summary by Sourcery
将与目录相关的空环境变量视为未设置,这样目录解析会回退到 XDG 或平台默认值,而不是使用无效的相对路径。
Bug Fixes:
MAA_*_DIR或XDG_*_HOME变量被设置为空字符串时,防止数据、缓存、状态和配置目录解析为意料之外的相对路径。Tests:
MAA_*_DIR和XDG_*_HOME环境变量会被忽略,并且行为与未设置变量时相同。Original summary in English
Summary by Sourcery
Treat empty directory-related environment variables as unset so directory resolution falls back to XDG or platform defaults instead of using invalid relative paths.
Bug Fixes:
Tests: