From 20810d137ade43e6a59fa926c00398c67c19cab7 Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Tue, 24 Mar 2026 17:03:56 +0800 Subject: [PATCH] fix: fix override path matching in reload hotloading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. 测试包含特殊字符的配置路径边界情况 --- dconfig-center/dde-dconfig-daemon/dconfig_global.h | 3 ++- dconfig-center/dde-dconfig-daemon/dconfigserver.cpp | 8 ++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/dconfig-center/dde-dconfig-daemon/dconfig_global.h b/dconfig-center/dde-dconfig-daemon/dconfig_global.h index edda033..a9ea532 100644 --- a/dconfig-center/dde-dconfig-daemon/dconfig_global.h +++ b/dconfig-center/dde-dconfig-daemon/dconfig_global.h @@ -95,7 +95,8 @@ inline ConfigureId getMetaConfigureId(const QString &path) { ConfigureId info; // /usr/share/dsg/configs/[$appid]/[$subpath]/$resource.json - static QRegularExpression usrReg(R"(/configs/(?([a-z0-9\s\-_\@\-\^!#$%&.]+\/)?)(?([a-z0-9\s\-_\@\-\^!#$%&.]+\/)*)(?[a-z0-9\s\-_\@\-\^!#$%&.]+).json$)"); + // Use negative lookahead (?!overrides/) to exclude override paths which should be handled by getOverrideConfigureId + static QRegularExpression usrReg(R"(/configs/(?!overrides/)(?([a-z0-9\s\-_\@\-\^!#$%&.]+\/)?)(?([a-z0-9\s\-_\@\-\^!#$%&.]+\/)*)(?[a-z0-9\s\-_\@\-\^!#$%&.]+).json$)"); QRegularExpressionMatch match; match = usrReg.match(path); diff --git a/dconfig-center/dde-dconfig-daemon/dconfigserver.cpp b/dconfig-center/dde-dconfig-daemon/dconfigserver.cpp index cd798bc..44efd78 100644 --- a/dconfig-center/dde-dconfig-daemon/dconfigserver.cpp +++ b/dconfig-center/dde-dconfig-daemon/dconfigserver.cpp @@ -379,12 +379,8 @@ ResourceKey DSGConfigServer::getResourceKeyByConfigCache(const ConfigCacheKey &k ConfigureId DSGConfigServer::getConfigureIdByPath(const QString &path) { - QFileInfo fileInfo(path); - if (!fileInfo.exists()) { - return ConfigureId(); - } - - const auto &absolutePath = fileInfo.absoluteFilePath(); + // Use absolute path for parsing, file may not exist (e.g., when deleted) + const auto &absolutePath = QFileInfo(path).absoluteFilePath(); auto res = getMetaConfigureId(absolutePath); if (res.isInValid()) {