fix: remove old cache on serial upgrade in repareCache - #151
Conversation
1. Add serial upgrade handling in repareCache() to remove old cache values when newMeta serial is greater than oldMeta serial 2. Add debug log for serial upgrade cache removal Log: Fixed dconfig write failure after serial upgrade Influence: 1. Test that cache values are removed when serial is upgraded 2. Verify dconfig set succeeds after serial upgrade with same value 3. Test that repareCache handles serial downgrade gracefully fix: repareCache添加serial升级时移除旧缓存处理 1. 在repareCache()中添加serial升级处理逻辑,当新meta的 serial大于旧meta的serial时移除旧缓存值 2. 添加serial升级缓存移除的调试日志 Log: 修复dconfig serial升级后写入相同值失败的问题 Influence: 1. 测试serial升级时缓存值是否被正确移除 2. 验证serial升级后使用相同值设置dconfig是否成功 3. 测试repareCache对serial降级的处理
|
Skipping CI for Draft Pull Request. |
There was a problem hiding this comment.
Sorry @deepin-wm, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm 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 |
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够优秀,无需额外修改。以下为保留原始逻辑的完整上下文示意:
void DSGConfigResource::repareCache(DConfigCache *cache, DConfigMeta *oldMeta, DConfigMeta *newMeta)
{
// ... (前置的 intersectKeys 处理逻辑) ...
// Serial升级时移除旧缓存值,serial升级意味着旧值必须废弃
for (const auto &key : intersectKeys) {
if (newMeta->serial(key) > oldMeta->serial(key)) {
cache->remove(key);
qDebug(cfLog, "Cache removed because of serial upgraded, resource:%s, uid:%d, key:%s.",
qPrintable(m_key), cache->uid(), qPrintable(key));
}
}
} |
When the serial of a dconfig configuration is upgraded, the old cache values should be discarded. Currently
repareCache()does not handle serial upgrades, causing the stale cache to persist andcheckSerial()to fail.Changes:
repareCache(): Added serial upgrade handling — whennewMeta->serial(key) > oldMeta->serial(key), usecache->remove(key)to remove the old cache value// Serial升级时移除旧缓存值,serial升级意味着旧值必须废弃