Skip to content

feat: Enhance time tracking in DiskBadSectorsDialog#161

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/1071from
itsXuSt:1071
Jul 22, 2025
Merged

feat: Enhance time tracking in DiskBadSectorsDialog#161
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/1071from
itsXuSt:1071

Conversation

@itsXuSt
Copy link
Copy Markdown
Contributor

@itsXuSt itsXuSt commented Jul 21, 2025

Changes:

  1. Added real-time tracking for elapsed time during disk checks.
  2. Implemented pause functionality to accurately account for time spent paused.
  3. Updated progress calculation based on actual elapsed time.

Log: Improved time management for disk sector checks, providing a more accurate user experience.

Bug: https://pms.uniontech.com/bug-view-324195.html

Summary by Sourcery

Implement high-precision time tracking in DiskBadSectorsDialog by using QDateTime for actual elapsed time, integrate pause/resume support, and update progress and remaining time estimations accordingly

New Features:

  • Track elapsed time in real time using system clock
  • Support pausing and resuming disk checks with accurate pause time tracking

Bug Fixes:

  • Prevent negative elapsed time and enforce a minimum remaining time threshold

Enhancements:

  • Calculate progress percentage based on cylinder count
  • Estimate remaining time using average time per cylinder from real elapsed time
  • Reset time tracking state on restart and reset actions

Changes:
1. Added real-time tracking for elapsed time during disk checks.
2. Implemented pause functionality to accurately account for time spent paused.
3. Updated progress calculation based on actual elapsed time.

Log: Improved time management for disk sector checks, providing a more accurate user experience.

Bug: https://pms.uniontech.com/bug-view-324195.html
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

代码审查意见:

.gitignore 文件

  • 新增的 .cursor/* 忽略规则是否必要?如果 .cursor 目录包含的是临时文件或不需要版本控制的文件,添加这个规则是合理的。如果这个目录包含的是需要版本控制的文件,应该移除这个规则。

diskbadsectorsdialog.cpp 文件

  • onStartVerifyButtonClicked 函数中,m_realStartTime 被初始化为当前时间戳,但没有检查文件是否成功打开。如果文件打开失败,应该有相应的错误处理逻辑。
  • onCheckTimeOut 函数中,realElapsedTime 的计算逻辑可能不准确,因为 m_totalPausedTime 是累加的暂停时间,但在计算 realElapsedTime 时没有考虑暂停期间的重复计算。
  • onCheckTimeOut 函数中,remainingTime 的计算逻辑可能不准确,特别是当 m_curCheckNumber 为 0 或 realElapsedTime 为 0 时,应该有更合理的处理方式。
  • onStopButtonClickedonContinueButtonClicked 函数中,m_pauseStartTime 的更新逻辑可能不准确,应该在暂停和继续操作时分别处理。
  • onAgainVerifyButtonClickedonResetButtonClicked 函数中,m_realStartTimem_totalPausedTimem_isPausedm_pauseStartTime 的重置逻辑应该保持一致,以确保时间跟踪的正确性。

diskbadsectorsdialog.h 文件

  • 新增的成员变量 m_realStartTimem_pauseStartTimem_totalPausedTimem_isPaused 应该有相应的注释说明其用途和作用。

通用建议

  • 代码中应该添加更多的错误处理逻辑,例如文件操作失败、网络请求失败等。
  • 代码中应该避免使用魔术数字,例如 1000,应该定义一个常量来代替。
  • 代码中应该有更多的注释来解释复杂的逻辑和算法,以提高代码的可读性和可维护性。
  • 代码中应该有单元测试来验证关键功能的正确性,确保代码的质量和稳定性。

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 21, 2025

Reviewer's Guide

This PR adds real-time tracking of disk check durations, including pause/resume support, and updates the timeout handler to compute progress and remaining time based on actual elapsed time rather than fixed estimates.

Class diagram for updated DiskBadSectorsDialog time tracking

classDiagram
    class DiskBadSectorsDialog {
        +void onStartVerifyButtonClicked()
        +void onCheckTimeOut()
        +void onStopButtonClicked()
        +void onContinueButtonClicked()
        +void onAgainVerifyButtonClicked()
        +void onResetButtonClicked()
        -- Time tracking fields --
        qint64 m_realStartTime
        qint64 m_pauseStartTime
        qint64 m_totalPausedTime
        bool m_isPaused
    }
Loading

File-Level Changes

Change Details Files
Introduced real-time tracking infrastructure
  • Imported QDateTime for timestamping
  • Declared m_realStartTime, m_pauseStartTime, m_totalPausedTime, m_isPaused in the dialog header
  • Initialized tracking variables in onStartVerifyButtonClicked
  • Reset tracking variables in onAgainVerifyButtonClicked and onResetButtonClicked
application/widgets/diskbadsectorsdialog.cpp
application/widgets/diskbadsectorsdialog.h
Enhanced timeout handler to compute progress and remaining time using real elapsed time
  • Calculated realElapsedTime from timestamps minus paused durations
  • Ensured non-negative elapsed time and fallback to estimatedTotalTime
  • Computed progressValue based on cylinder counts
  • Estimated remainingTime using average time per cylinder or fallback logic and updated UI labels accordingly
application/widgets/diskbadsectorsdialog.cpp
Added pause and resume support to account for paused duration
  • Recorded pause start time and flagged pause state in onStopButtonClicked
  • Accumulated totalPausedTime and cleared pause state in onContinueButtonClicked
application/widgets/diskbadsectorsdialog.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

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: itsXuSt, max-lvs

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

@itsXuSt
Copy link
Copy Markdown
Contributor Author

itsXuSt commented Jul 22, 2025

/merge

@deepin-bot deepin-bot Bot merged commit 68d75af into linuxdeepin:release/1071 Jul 22, 2025
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