Repository navigation
fix: handle missing subdirectories in override file loading - #604
Merged
Merged
Conversation
Reviewer's GuideImplementationNormalize the configured subpath and fall back to the deepest existing directory so override loading can continue through parent directories when parts of the path are missing.
TestsAdd coverage for missing and partially existing subpaths, parent override inheritance, and leaf-level override precedence.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
BLumia
approved these changes
Nov 25, 2026
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/dconfigfile.cpp" line_range="990" />
<code_context>
+ // Start at the deepest existing subdirectory before walking back up.
+ QString subpath = QDir::cleanPath(configKey.subpath);
+ while (subpath.size() > 1 && !target_dir.cd(subpath.mid(1)))
+ subpath.truncate(subpath.lastIndexOf(QLatin1Char('/')));
do {
</code_context>
<issue_to_address>
**Partial paths follow symlinks**
When a configured subpath has an existing symlink component pointing outside the override directory, followed by a missing component, `target_dir.cd()` follows an existing symlink component, so fallback can scan override files outside the configured override directory and apply them to the config.
Before scanning a fallback directory, verify its resolved canonical path remains inside the canonical override base, or reject symlink components.
</issue_to_address>1. Replace direct cd() call with cleanPath and a walk-back loop that attempts to enter the deepest existing subdirectory 2. Truncate the subpath at the last slash when cd() fails until a valid directory is found or only root remains 3. This prevents silent failure to load override files when the configured subpath or intermediate directories do not exist on disk 4. Add unit tests covering missing subpaths, deeply nested non-existent paths, existing leaf directories without overrides, and leaf override precedence Influence: 1. Test override loading when the configured subpath does not exist at all 2. Verify that parent directory overrides are correctly inherited for missing nested subpaths 3. Test behavior when the leaf directory exists but contains no override files 4. Verify that a leaf-level override takes precedence over parent overrides 5. Confirm no regression in existing fileOverride and fileOverrideNoExistItem tests 6. Test with paths containing redundant separators or dot segments via QDir::cleanPath fix: 修复配置覆盖搜索中缺失子路径的处理 1. 用 cleanPath 和回退循环替代直接 cd() 调用,尝试进入最深的已存在子目录 2. 当 cd() 失败时截断子路径到最后一个斜杠,直到找到有效目录或仅剩根目录 3. 避免配置的子路径或中间目录在磁盘上不存在时静默无法加载覆盖文件 4. 新增单元测试覆盖缺失子路径、深层不存在的路径、存在但无覆盖文件的叶子 目录以及叶子覆盖优先级 Influence: 1. 测试配置子路径完全不存在时的覆盖加载 2. 验证缺失嵌套子路径时能正确继承父目录覆盖 3. 测试叶子目录存在但不包含覆盖文件时的行为 4. 验证叶子级覆盖优先于父级覆盖 5. 确认现有 fileOverride 和 fileOverrideNoExistItem 测试无回归 6. 通过 QDir::cleanPath 测试包含冗余分隔符或点段的路径 Log: Fixed config override loading when subpath directories are missing PMS: TASK-399295
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: blocked) |
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.
until an existing directory is found
to parent directories
inheritance behavior
Previously, if the configured subpath did not exist on disk, cd() would
fail silently and the override file search would not traverse parent
directories. This caused override files at parent levels to be missed
when a deeper subpath was configured but not yet created.
Influence:
verify parent override is still applied
but child does not)
parent overrides are inherited
parent overrides
missing levels
fix: 修复覆盖文件加载时子目录不存在的问题
此前,当配置的子路径在磁盘上不存在时,cd() 会静默失败,覆盖文件搜索不会
遍历父目录。这导致当配置了更深的子路径但尚未创建时,父级的覆盖文件会被
遗漏。
Influence:
PMS: TASK-399295
Summary by Sourcery
Fix override file loading so missing subdirectories fall back to the deepest existing directory and continue inheriting parent overrides.
Bug Fixes:
Enhancements:
Tests: