Skip to content

Commit c1f7371

Browse files
committed
fix: fix override path matching in reload hotloading
The issue was that during hot reload operations, override configuration paths were being incorrectly matched by the getMetaConfigureId function instead of being handled by getOverrideConfigureId. This caused override configurations to fail during reload operations. The fix modifies the regular expression in getMetaConfigureId to exclude override paths using negative lookahead (?!overrides/). This ensures that override paths are properly routed to getOverrideConfigureId for correct processing. Additionally, the getConfigureIdByPath function was updated to not check for file existence before parsing, as files may not exist during deletion operations but still need path parsing. Log: Fixed hot reload functionality for override configuration paths Influence: 1. Test hot reload functionality with override configurations 2. Verify that override paths are correctly identified and processed 3. Test configuration deletion and reload scenarios 4. Validate both standard and override configuration paths work correctly 5. Test edge cases with special characters in configuration paths fix: 修复热加载中覆盖路径匹配问题 问题在于热重载操作期间,覆盖配置路径被 getMetaConfigureId 函数错误匹配, 而不是由 getOverrideConfigureId 处理。这导致覆盖配置在重载操作期间失效。 修复方案修改了 getMetaConfigureId 中的正则表达式,使用负向先 行断言 (?!overrides/) 排除覆盖路径。这确保覆盖路径能正确路由到 getOverrideConfigureId 进行处理。此外,更新了 getConfigureIdByPath 函 数,使其在解析前不检查文件是否存在,因为在删除操作期间文件可能不存在但仍 需要路径解析。 Log: 修复了覆盖配置路径的热重载功能 Influence: 1. 测试覆盖配置的热重载功能 2. 验证覆盖路径是否正确识别和处理 3. 测试配置删除和重载场景 4. 验证标准和覆盖配置路径都能正常工作 5. 测试包含特殊字符的配置路径边界情况
1 parent b30cf4c commit c1f7371

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

dconfig-center/dde-dconfig-daemon/dconfig_global.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ inline ConfigureId getMetaConfigureId(const QString &path)
9595
{
9696
ConfigureId info;
9797
// /usr/share/dsg/configs/[$appid]/[$subpath]/$resource.json
98-
static QRegularExpression usrReg(R"(/configs/(?<appid>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)?)(?<subpath>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)*)(?<resource>[a-z0-9\s\-_\@\-\^!#$%&.]+).json$)");
98+
// Use negative lookahead (?!overrides/) to exclude override paths which should be handled by getOverrideConfigureId
99+
static QRegularExpression usrReg(R"(/configs/(?!overrides/)(?<appid>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)?)(?<subpath>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)*)(?<resource>[a-z0-9\s\-_\@\-\^!#$%&.]+).json$)");
99100

100101
QRegularExpressionMatch match;
101102
match = usrReg.match(path);

dconfig-center/dde-dconfig-daemon/dconfigserver.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,8 @@ ResourceKey DSGConfigServer::getResourceKeyByConfigCache(const ConfigCacheKey &k
379379

380380
ConfigureId DSGConfigServer::getConfigureIdByPath(const QString &path)
381381
{
382-
QFileInfo fileInfo(path);
383-
if (!fileInfo.exists()) {
384-
return ConfigureId();
385-
}
386-
387-
const auto &absolutePath = fileInfo.absoluteFilePath();
382+
// Use absolute path for parsing, file may not exist (e.g., when deleted)
383+
const auto &absolutePath = QFileInfo(path).absoluteFilePath();
388384

389385
auto res = getMetaConfigureId(absolutePath);
390386
if (res.isInValid()) {

0 commit comments

Comments
 (0)