Skip to content

fix: add clear to initCmd for idempotency - #863

Draft
add-uos wants to merge 2 commits into
linuxdeepin:masterfrom
add-uos:agent/bug/55a168cf6bd7
Draft

add-uos wants to merge 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 GetInfoPool command initialization produces a consistent command list without affecting the normal single-call flow.

Bug Fixes:

  • Make device information command initialization idempotent by preventing duplicate commands when it 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

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

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

@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

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

Reviewer's Guide

Adds an upfront clear to GetInfoPool::initCmd() so repeated initialization rebuilds the command list without duplicates, while preserving the existing single-call device information collection behavior.

Sequence diagram for idempotent command initialization

sequenceDiagram
    participant Caller
    participant GetInfoPool
    participant m_CmdList

    Caller->>GetInfoPool: initCmd()
    GetInfoPool->>m_CmdList: clear()
    GetInfoPool->>m_CmdList: append 29 commands
    GetInfoPool-->>Caller: command list ready

    Caller->>GetInfoPool: initCmd()
    GetInfoPool->>m_CmdList: clear()
    GetInfoPool->>m_CmdList: append 29 commands
    GetInfoPool-->>Caller: command list ready
Loading

File-Level Changes

Change Details Files
Make command-list initialization idempotent by resetting existing entries before repopulation.
  • Clear m_CmdList at the beginning of initCmd()
  • Preserve the existing command definitions and normal single-call behavior
deepin-devicemanager/src/GenerateDevice/GetInfoPool.cpp
Validate repeated initialization and ensure device-information collection remains unaffected.
  • Confirm two consecutive initCmd() calls leave 29 commands
  • Verify device info collection and existing flow do not regress

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

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.

2 participants