Skip to content

fix: add clear to initCmd for idempotency - #863

Merged
deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
add-uos:agent/bug/55a168cf6bd7
Oct 29, 2026
Merged

deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
add-uos:agent/bug/55a168cf6bd7

Conversation

@add-uos

@add-uos add-uos commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

fix: add clear to initCmd for idempotency

  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

Summary by Sourcery

Ensure repeated command-list initialization starts from a clean state.

Bug Fixes:

  • Make GetInfoPool command initialization idempotent by preventing duplicate commands when initCmd() is called repeatedly.

Chores:

  • Update the GetInfoPool source copyright range.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

GetInfoPool::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 initialization

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Make command-list initialization idempotent by resetting existing entries before repopulation.
  • Clear the command list at the start of initialization.
  • Preserve the existing command definitions and single-call behavior.
  • Update the source copyright range.
deepin-devicemanager/src/GenerateDevice/GetInfoPool.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

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.
@add-uos
add-uos force-pushed the agent/bug/55a168cf6bd7 branch from 75b7239 to 228c44f Compare October 27, 2026 03:45
@deepin-bot

deepin-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.75
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #956

@add-uos
add-uos marked this pull request as ready for review October 29, 2026 08:06
@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交在 GetInfoPool::initCmd() 函数中添加 m_CmdList.clear() 调用,确保函数的幂等性,防止重复调用时命令列表累积重复条目。变更内容正确、目标明确,四维度均无问题,OCR 审查同样未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 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 代码审查工具自动生成

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@add-uos

add-uos commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit 0cdf58d into linuxdeepin:master Oct 29, 2026
14 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants