Skip to content

fix: show hint when mkfs progress reaches cap - #51

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/eaglefrom
tianming-1996:fix/mkfs-progress-hint
Nov 5, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/eaglefrom
tianming-1996:fix/mkfs-progress-hint

Conversation

@tianming-1996

@tianming-1996 tianming-1996 commented Nov 4, 2026 •

Copy link
Copy Markdown

修复:格式化 EXT3 卡在 99% (PMS BUG-291279)

根因

MainWindow::initConnect() 中 mkfs(快速格式化)路径使用固定速率模拟进度(0.06/300ms),约 5 秒到达 0.99 上限后停住。大容量磁盘 mkfs.ext3 实际耗时数十秒至数分钟,进度条长时间停留在 99% 且没有任何提示,用户误以为程序卡死。

实机复现数据(114.5 GB USB 机械盘,快速格式化 ext3):

Filesystem created:  13:56:28
Last write time:     13:57:00     ← 真实 mkfs 耗时 32 秒
写盘量: 2.30 GiB (inode 表 1.79 GiB + journal 0.5 GiB)
进度条停在 99% 的时长: 约 28 秒

同盘对照:ext4 只需 8.63 秒(有 uninit_bg,inode 表延迟初始化),ext3 必须写满 inode 表,慢 3.7 倍。

修复方案:保留 99% 封顶,仅补充提示

} else {
    m_formatingPage->setProgress(0.99);              // 不变
    m_formatingPage->setHintText(tr("Large capacity disks may take longer"));
    timer->stop();
}

不在 0.99 → 0.95 上做改动,原因:0.06 × 16 = 0.96 会先显示 96%,下一拍才进 else 设成 95%,进度条会当着用户的面倒退一格。而 95% 与 99% 在用户感知上没有区别,真正解决"像卡死"的是提示文字。保留 0.99 意味着完全不动已有进度逻辑,零回归风险。

同时修复:失败重试时提示残留

FormatingPage 在构造函数中只创建一次,格式化失败后用户点「重新格式化」走 FormattError → Normal → Warn → Formating,复用同一个页面对象。setHintText() 只有 show() 没有 hide(),导致第二次格式化时进度条刚从 0% 爬升,提示文字已经挂在界面上了。

新增 FormatingPage::reset(),在 formatDevice() 开头调用(erase 和 mkfs 两条路径的唯一入口):

void FormatingPage::reset()
{
    if (m_hintLabel) {
        m_hintLabel->clear();
        m_hintLabel->hide();
    }
    // setProgress 会跳过 0 值,这里直接复位动画进度
    if (m_progressBox) {
        m_progressBox->setValue(1);
    }
}

改动文件

文件 改动
view/formatingpage.h 新增 QLabel 前置声明、setHintText()/reset() 接口、m_hintLabel 成员
view/formatingpage.cpp initUI() 中创建提示标签(自动换行、居中、默认隐藏),实现两个新方法
view/mainwindow.cpp 封顶时调用 setHintText() 并停止定时器;formatDevice() 开头调用 reset()
translations/dde-device-formatter.ts 新增词条
translations/dde-device-formatter_zh_CN.ts 新增词条及中文翻译

验证

代码层(FormatingPage 独立 UI 测试,Qt5 + Dtk,offscreen):

===== 首次格式化 =====
初始(0%) 提示可见: NO
到顶后 提示可见  : YES
到顶后 文字      : 大容量磁盘可能需要较长时间
到顶后 行数      : 1 行

===== 模拟失败后重试 =====
reset 后 提示可见 : NO
reset 后 提示文字 : ""
重试 6% 时提示    : NO

===== 重试再次到顶 =====
再次到顶 提示可见 : YES
再次到顶 文字正确 : YES
标签唯一性        : YES

文案在不同宽度下的排版(实测主窗口 1040 px):

页面宽度 文字宽 行数
320 px 323 px 2 行
360 ~ 1040 px 323 px 1 行

真机验证(UOS 20 专业版 arm64, 5.10.97):编译通过,无错误无警告;strings 确认新串已编入二进制;lconvert 反解 qm 确认中文翻译正确。

影响范围

  • 仅影响 mkfs(快速格式化)路径
  • erase(完整格式化)路径使用真实的 progressChanged 信号,未改动
  • DUDisksJob::completed → setProgress(1) → onFormatingFinished 完成链路未改动,进度仍能正常到 100%

测试建议

  1. 小容量磁盘快速格式化 —— 无提示,正常完成
  2. 大容量磁盘快速格式化 —— 进度停在 99% 并显示提示,完成后跳到 100%
  3. 格式化失败后重试 —— 提示不应在封顶前出现
  4. 取消勾选快速格式化(走 erase)—— 行为不受影响

PMS: BUG-291279

Summary by Sourcery

Prevent quick formatting from appearing stuck at 99% by showing a large-disk wait hint and resetting formatting state on retries.

New Features:

  • Display a localized hint when quick formatting reaches the 99% progress cap on large-capacity disks.

Bug Fixes:

  • Clear stale formatting hints and reset progress when restarting a failed formatting operation.

Enhancements:

  • Add a reusable formatting-page hint label with reset behavior for both formatting paths.

@sourcery-ai

sourcery-ai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR addresses the apparent 99% hang during slow mkfs.ext3 operations by showing a localized large-disk hint and stopping the simulated progress timer at the existing cap, while resetting the reusable formatting page so retries start without stale hints or progress.

Sequence diagram for capped quick-format progress hint

sequenceDiagram
    participant MainWindow
    participant FormatingPage
    participant Timer
    participant DUDisksJob

    MainWindow->>Timer: start(300)
    loop simulated progress
        Timer->>MainWindow: timeout
        MainWindow->>FormatingPage: setProgress(progress)
    end
    Timer->>MainWindow: timeout at cap
    MainWindow->>FormatingPage: setProgress(0.99)
    MainWindow->>FormatingPage: setHintText(tr(...))
    MainWindow->>Timer: stop()
    DUDisksJob->>FormatingPage: setProgress(1)
    DUDisksJob->>MainWindow: completed
Loading

Sequence diagram for formatting retry reset

sequenceDiagram
    participant User
    participant MainWindow
    participant FormatingPage
    participant DWaterProgress

    User->>MainWindow: formatDevice()
    MainWindow->>FormatingPage: reset()
    FormatingPage->>DWaterProgress: setValue(1)
    FormatingPage-->>MainWindow: hint cleared and hidden
    MainWindow->>FormatingPage: setProgress(progress)
    FormatingPage-->>User: fresh formatting progress
Loading

File-Level Changes

Change Details Files
Adds a user-visible hint when simulated quick-format progress reaches its 99% cap, while preserving the existing progress behavior and stopping the simulation timer.
  • Displays a localized large-disk duration hint at the cap.
  • Stops further simulated progress updates after reaching the cap.
  • Leaves erase-format progress and completion handling unchanged.
view/mainwindow.cpp
translations/dde-device-formatter.ts
translations/dde-device-formatter_zh_CN.ts
Resets the shared formatting page before every formatting attempt to prevent stale hints and progress from appearing during retries.
  • Adds a reset API that hides and clears the hint label.
  • Directly resets the water-progress widget to its initial value.
  • Invokes reset at the common format-device entry point for both formatting paths.
view/formatingpage.h
view/formatingpage.cpp
view/mainwindow.cpp
Introduces a hidden, centered, wrapping hint label to the formatting page and updates translation metadata for shifted source locations.
  • Creates and lays out the hint label below the formatting message.
  • Adds English and Simplified Chinese translations for the new hint.
view/formatingpage.cpp
translations/dde-device-formatter.ts
translations/dde-device-formatter_zh_CN.ts

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

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@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 ✨

@tianming-1996
tianming-1996 force-pushed the fix/mkfs-progress-hint branch from a21697c to 684277c Compare November 4, 2026 09:14
1. Root cause: mkfs (quick format) simulates progress at a fixed rate
   (0.06 per 300ms), reaching the 0.99 cap in about 5 seconds, while
   mkfs.ext3 on a large disk takes tens of seconds to minutes. The
   progress indicator sits at 99% with no feedback, so users believe
   the program has frozen.
2. Fix: keep the 0.99 cap unchanged and show a hint text "Large capacity
   disks may take longer" once progress caps; stop the timer after
   capping to avoid repeated setHintText() calls. Add FormatingPage::reset()
   and call it from formatDevice(), because the formating page is reused
   when the user retries after a failure and would otherwise keep the
   stale hint visible from 0%; fill in the new string for both the
   English and zh_CN translation files.
3. Impact: the mkfs path only; the erase path and the DUDisksJob::completed
   chain are unchanged, so progress still reaches 100% on completion.

Log: Show hint when mkfs progress reaches the cap

Influence:
1. Format a small disk with quick format (no hint, completes normally)
2. Format a large disk with quick format (progress caps at 99% with hint)
3. Fail a format then retry (hint must not appear before the cap)
4. Verify the erase format path is unaffected

PMS: BUG-291279
@tianming-1996
tianming-1996 force-pushed the fix/mkfs-progress-hint branch from 684277c to 203c3fe Compare November 4, 2026 09:17
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交目的是在 mkfs 进度模拟达到上限时显示"大容量磁盘可能需要较长时间"的提示, 并为失败重试场景增加 reset() 方法清除上一轮残留状态。变更涉及 5 个文件 (2 个翻译文件、formatingpage.cpp/.h、mainwindow.cpp),新增代码结构清晰、 逻辑正确、无安全漏洞。启发式扫描、OCR 审查、AI 四维度分析三方均未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: []


2. 代码质量 ✅

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

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

建议: []


3. 代码性能 ✅

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

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

建议: []


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

本次代码质量良好,无需修复。以下为当前实现的关键代码片段,供参考:
// formatingpage.cpp - reset() 方法实现 void FormatingPage::reset() {
    if (m_hintLabel) {
        m_hintLabel->clear();
        m_hintLabel->hide();
    }
    // setProgress 会跳过 0 值,这里直接复位动画进度
    if (m_progressBox) {
        m_progressBox->setValue(1);
    }
}

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@tianming-1996

Copy link
Copy Markdown
Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit 1cbd333 into linuxdeepin:develop/eagle Nov 5, 2026
17 of 18 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