Skip to content

Pr0807#166

Merged
lzwind merged 3 commits intolinuxdeepin:masterfrom
wangrong1069:pr0807
Aug 7, 2025
Merged

Pr0807#166
lzwind merged 3 commits intolinuxdeepin:masterfrom
wangrong1069:pr0807

Conversation

@wangrong1069
Copy link
Contributor

@wangrong1069 wangrong1069 commented Aug 7, 2025

Summary by Sourcery

Fix variable assignment in storage size parsing and simplify disk media type detection by removing redundant error handling.

Bug Fixes:

  • Correct the assignment from m_interface to m_size when parsing size from lshw output.
  • Remove exit code check that returned "UnKnow" in getDiskInfoMediaType to streamline media type detection.

Some USB device information acquisition failures may occur; these should be ignored.

Failure example:
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-6.6.0-amd64-desktop] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               aigo
Product:              U268
Revision:             2.00
Compliance:           SPC-2
User Capacity:        62,914,560,000 bytes [62.9 GB]
Logical block size:   512 bytes
scsiModePageOffset: response length too short, resp_len=4 offset=4 bd_len=0
scsiModePageOffset: response length too short, resp_len=4 offset=4 bd_len=0
>> Terminate command early due to bad response to IEC mode page
A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.

Log: Fix fail to get info from some USB device
Bug: https://pms.uniontech.com/bug-view-303363.html
The value of m_size is incorrectly stored in m_interface.

Log: Fix disk interface display abnormality
Bug: https://pms.uniontech.com/bug-view-327617.html
As title.

Log: Update version to 6.0.12
@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • DeviceStorage.cpp文件中,getInfoFromLshw函数中正则表达式匹配后,错误地修改了m_interface变量的值,应该是m_size
  • getDiskInfoMediaType函数中,qDebug语句用于调试,但在生产环境中应该移除或替换为更合适的日志记录方式。
  • getDiskInfoMediaType函数中,qDebug语句在exitcode != 0时打印错误信息,但没有处理错误情况,应该添加错误处理逻辑。

是否建议立即修改:

@github-actions
Copy link

github-actions bot commented Aug 7, 2025

TAG Bot

TAG: 6.0.12
EXISTED: no
DISTRIBUTION: unstable

@sourcery-ai
Copy link

sourcery-ai bot commented Aug 7, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR corrects the variable used when parsing disk size from lshw output and removes the early exit on smartctl failures to streamline disk media type detection.

Class diagram for DeviceStorage changes

classDiagram
    class DeviceStorage {
        +void getInfoFromLshw(const QMap<QString, QString> &mapInfo)
        +QString getDiskInfoMediaType(const QString &devicePath)
        -QString m_interface
        +QString m_size
    }
Loading

File-Level Changes

Change Details Files
Fix parsing assignment for disk size
  • Replace incorrect m_interface assignment with m_size when capturing size
service/diskoperation/DeviceStorage.cpp
Remove smartctl exit code check and early return
  • Delete the exitcode != 0 conditional block
  • Remove debug log and UnKnow return on smartctl failure
service/diskoperation/DeviceStorage.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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @wangrong1069 - I've reviewed your changes - here's some feedback:

  • After removing the exitcode check in getDiskInfoMediaType, consider adding explicit handling or logging for non-zero exit codes to avoid silent failures or uninitialized return values.
  • Verify that changing the assignment from m_interface to m_size in getInfoFromLshw doesn’t leave m_interface unset in other parts of the code that rely on it.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- After removing the exitcode check in getDiskInfoMediaType, consider adding explicit handling or logging for non-zero exit codes to avoid silent failures or uninitialized return values.
- Verify that changing the assignment from m_interface to m_size in getInfoFromLshw doesn’t leave m_interface unset in other parts of the code that rely on it.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, wangrong1069

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

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