Repository navigation
fix: add clear to initCmd for idempotency - #863
Conversation
|
Skipping CI for Draft Pull Request. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideGetInfoPool::initCmd() now clears its command list before appending commands, preventing duplicates on repeated initialization while preserving the normal device-information collection flow; the source copyright range is also updated. Sequence diagram for idempotent command initializationsequenceDiagram
participant Caller
participant GetInfoPool
Caller->>GetInfoPool: initCmd()
GetInfoPool->>GetInfoPool: m_CmdList.clear()
GetInfoPool->>GetInfoPool: m_CmdList.append(...)
GetInfoPool-->>Caller: command list initialized
Caller->>GetInfoPool: initCmd()
GetInfoPool->>GetInfoPool: m_CmdList.clear()
GetInfoPool->>GetInfoPool: m_CmdList.append(...)
GetInfoPool-->>Caller: same command list without duplicates
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Root cause: GetInfoPool::initCmd() only appends commands to m_CmdList without clearing it first, making the method non-idempotent; repeated calls double the command count 2. Fix: add m_CmdList.clear() at the start of initCmd() so the method always starts from an empty list 3. Impact: no behavior change for normal single-call path, only fixes the duplicate-command issue when called multiple times Influence: 1. Verify device info collection works correctly after fix 2. Verify command list size is 29 after calling initCmd twice 3. Verify no regression on existing device info collection flow fix: initCmd方法添加clear确保幂等性 1. 根因:GetInfoPool::initCmd() 仅通过 append 追加命令到 m_CmdList,未先清空,方法不具备幂等性,重复调用导致 命令表翻倍 2. 方案:在 initCmd() 开头添加 m_CmdList.clear(),使方法 每次从空列表开始初始化 3. 影响:正常单次调用路径无行为变化,仅修复重复调用时 命令重复问题 Influence: 1. 验证修复后设备信息采集功能正常 2. 验证连续调用两次initCmd后命令列表数量仍为29 3. 验证现有设备信息采集流程无回归 PMS: BUG-DEF-003
The license-check CI (SPDX Header Validation) requires files created in earlier years and modified in 2026 to carry a copyright year range ending with the current year. Extend the SPDX-FileCopyrightText header of GetInfoPool.cpp from 2022 to 2022-2026 so the SPDX summary reports 0 failures.
75b7239 to
228c44f
Compare
|
TAG Bot New tag: 6.0.75 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 当前代码已正确,无需修改。
// initCmd() 函数在追加命令前先清空列表,确保幂等性:
//
// void GetInfoPool::initCmd()
// {
// qCDebug(appLog) << "GetInfoPool::initCmd start";
// m_CmdList.clear(); // 确保幂等性,防止重复调用时累积重复条目
// m_CmdList.append({ "lshw", "lshw.txt", tr("Loading Audio Device Info...") });
// m_CmdList.append({ "printer", "printer.txt", "" });
// // ...
// }本报告由 AI 代码审查工具自动生成 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
fix: add clear to initCmd for idempotency
m_CmdList without clearing it first, making the method
non-idempotent; repeated calls double the command count
method always starts from an empty list
fixes the duplicate-command issue when called multiple times
Influence:
fix: initCmd方法添加clear确保幂等性
m_CmdList,未先清空,方法不具备幂等性,重复调用导致
命令表翻倍
每次从空列表开始初始化
命令重复问题
Influence:
PMS: BUG-DEF-003
Summary by Sourcery
Ensure repeated command-list initialization starts from a clean state.
Bug Fixes:
Chores: