Skip to content

fix: add dvd+rw-format support for DVD RW erase (develop/eagle) - #402

Closed
liyigang1 wants to merge 1 commit into
linuxdeepin:develop/eaglefrom
liyigang1:fix/dvdrw-format-develop-eagle
Closed

liyigang1 wants to merge 1 commit into
linuxdeepin:develop/eaglefrom
liyigang1:fix/dvdrw-format-develop-eagle

Conversation

@liyigang1

@liyigang1 liyigang1 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

修复内容

PMS bug 276977:DVD±RW 擦除失败——DOpticalDiscManager::erase() 仅使用 xorriso,部分 DVD±RW 介质擦除失败。

源修复 commit 236f0d4(master 分支)新增 DVDRwFormatEngine,使用 dvd+rw-format 进行 DVD±RW 分流擦除,xorriso 作为降级方案。

改动文件

  • src/dfm-burn/dfm-burn-lib/private/dvdrwformatengine.h — DVDRwFormatEngine 头文件
  • src/dfm-burn/dfm-burn-lib/private/dvdrwformatengine.cpp — DVDRwFormatEngine 实现
  • src/dfm-burn/dfm-burn-lib/dopticaldiscmanager.cpp — erase() 中调用 DVDRwFormatEngine
  • debian/control — libdfm-burn Depends 添加 dvd+rw-tools

验证

  • 代码 cherry-pick 自 master 236f0d4,已解决分支差异冲突
  • dde-file-manager 的 burnjob.cpp 正确调用 DOpticalDiscManager::erase(),无需修改 dde-file-manager

Summary by Sourcery

Enable reliable DVD±RW disc erasure through dvd+rw-format with xorriso fallback.

New Features:

  • Add DVD±RW erasure support using dvd+rw-format with media-specific handling and progress reporting.

Bug Fixes:

  • Fix DVD±RW erase failures by selecting dvd+rw-format when available while retaining xorriso fallback support.

Build:

  • Add dvd+rw-tools as a runtime dependency.

1. Added new DVDRwFormatEngine class to handle DVD RW erasure using
dvd+rw-tools
2. Modified control files to add dvd+rw-tools as a dependency
3. Updated DOpticalDiscManager to detect DVD±RW media and use new engine
when available
4. Implemented progress parsing for dvd+rw-format's special output
format
5. Added fallback to xorriso when dvd+rw-format is not available

Log: Added support for DVD±RW erasure using dvd+rw-format tool

Influence:
1. Test DVD+RW and DVD-RW erasure with dvd+rw-tools installed
2. Verify fallback to xorriso when dvd+rw-tools is missing
3. Check progress reporting during erase operations
4. Test with different DVD RW media types
5. Verify no regression in CD/DVD non-RW erase functionality

feat: 添加对DVD RW擦除的dvd+rw-format支持

1. 新增DVDRwFormatEngine类用于通过dvd+rw-tools处理DVD RW擦除
2. 修改控制文件添加dvd+rw-tools作为依赖项
3. 更新DOpticalDiscManager以检测DVD±RW介质并在可用时使用新引擎
4. 实现针对dvd+rw-format特殊输出格式的进度解析
5. 添加当dvd+rw-format不可用时回退到xorriso的处理

Log: 新增使用dvd+rw-format工具进行DVD±RW擦除的支持

Influence:
1. 测试dvd+rw-tools安装时的DVD+RW和DVD-RW擦除功能
2. 验证dvd+rw-tools缺失时回退到xorriso的功能
3. 检查擦除过程中的进度报告
4. 使用不同类型的DVD RW介质进行测试
5. 验证普通CD/DVD非RW擦除功能无回归
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: liyigang1

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 Sep 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

DVD±RW erasure now uses a dedicated dvd+rw-format process with media-specific operations and aggregated progress reporting, while retaining xorriso as a fallback and packaging the required utility dependency.

Sequence diagram for dvd+rw-format DVD±RW erasure

sequenceDiagram
    participant M as DOpticalDiscManager
    participant E as DVDRwFormatEngine
    participant P as dvd+rw-format

    M->>M: createOpticalInfo
    M->>E: doErase(device, mediaType)
    E->>P: start(args)
    loop Poll process output
        E->>P: waitForReadyRead
        P-->>E: progress output
        E->>E: parseProgress
        E-->>M: jobStatusChanged(status, progress)
    end
    P-->>E: exit code
    E-->>M: jobStatusChanged(kFinished, 100)
Loading

Flow diagram for DVD±RW erase engine selection

flowchart TD
    A[DOpticalDiscManager::erase] --> B[createOpticalInfo]
    B --> C{DVD±RW media?}
    C -->|No| D[DXorrisoEngine]
    C -->|Yes| E{dvd+rw-format available?}
    E -->|No| D
    E -->|Yes| F[DVDRwFormatEngine::doErase]
    F --> G[Erase with dvd+rw-format]
    D --> H[xorriso erase]
Loading

File-Level Changes

Change Details Files
Introduce a dedicated DVD±RW erase engine backed by dvd+rw-format, with media-specific commands and progress reporting.
  • Validate optical device paths and supported media types.
  • Use force formatting for DVD+RW and full blanking for DVD-RW.
  • Run the external process synchronously while polling merged output and translating multi-phase percentage output into aggregate progress.
  • Report start, completion, and failure states through the engine signal.
src/dfm-burn/dfm-burn-lib/private/dvdrwformatengine.h
src/dfm-burn/dfm-burn-lib/private/dvdrwformatengine.cpp
Route DVD±RW erasure through dvd+rw-format when available while preserving xorriso fallback behavior.
  • Detect the current media type before erasing.
  • Locate dvd+rw-format and forward engine status updates to the optical disc manager.
  • Fall back to the existing xorriso erase path with a warning when the utility is unavailable.
src/dfm-burn/dfm-burn-lib/dopticaldiscmanager.cpp
Add the external utility as a runtime package dependency.
  • Declare dvd+rw-tools in libdfm-burn dependencies.
debian/control

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

@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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/dfm-burn/dfm-burn-lib/private/dvdrwformatengine.cpp" line_range="31-32" />
<code_context>
+
+    // 1. 校验设备路径
+    QString cleanDev = QDir::cleanPath(dev);
+    if (!cleanDev.startsWith("/dev/sr")) {
+        qWarning() << "[dfm-burn] Invalid device path:" << dev;
+        Q_EMIT jobStatusChanged(JobStatus::kFailed, -1);
+        return false;
</code_context>
<issue_to_address>
**issue (bug_risk):** `doErase` rejects valid optical-drive symlink paths such as `/dev/dvd` and `/dev/cdrom` because it requires the cleaned path to start with `/dev/sr`, so DVD±RW erase fails instead of invoking `dvd+rw-format`.

**Triggers:** When DOpticalDiscManager is constructed with a standard `/dev/dvd` or `/dev/cdrom` symlink.

**Suggested fix:** Validate the resolved device with `QFileInfo::canonicalFilePath()` or accept supported optical-drive symlinks rather than requiring the `/dev/sr*` spelling.
</issue_to_address>

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

Comment on lines +31 to +32
if (!cleanDev.startsWith("/dev/sr")) {
qWarning() << "[dfm-burn] Invalid device path:" << dev;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): doErase rejects valid optical-drive symlink paths such as /dev/dvd and /dev/cdrom because it requires the cleaned path to start with /dev/sr, so DVD±RW erase fails instead of invoking dvd+rw-format.

Triggers: When DOpticalDiscManager is constructed with a standard /dev/dvd or /dev/cdrom symlink.

Suggested fix: Validate the resolved device with QFileInfo::canonicalFilePath() or accept supported optical-drive symlinks rather than requiring the /dev/sr* spelling.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 99 分,大于 70 分通过阈值,代码质量符合要求。本次提交为 DVD±RW 擦除功能添加了 dvd+rw-format 引擎支持,代码结构清晰,注释详尽,安全无漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 语法正确,逻辑清晰,边界处理完善。erase() 方法正确查询介质类型、检查 dvd+rw-format 可用性并降级到 xorriso;doErase() 正确验证设备路径、选择命令参数、轮询进程输出、解析进度并处理退出码。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. src/dfm-burn/dfm-burn-lib/private/dvdrwformatengine.cpp:105 - 设备路径校验 startsWith("/dev/sr") 较为宽松,建议使用正则 /dev/sr[0-9]+ 精确匹配光驱设备路径

建议: 代码结构清晰,注释完整。注释详细解释了 dvd+rw-format 的进度输出机制、SCSI 操作阶段和 waitForReadyRead 的选用原因。建议将设备路径校验改为更精确的正则匹配。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 性能良好,资源使用合理。使用 static const QRegularExpression 避免重复编译;缓冲区大小限制在 1024 字节防止无限增长;200ms 轮询间隔合理;waitForReadyRead 内部调用 processEvents 确保信号实时传递。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 存在0个安全漏洞,安全合规。QProcess::start() 使用 QStringList 参数避免命令注入;QDir::cleanPath() 规范化路径并前缀校验防止路径遍历;QStandardPaths::findExecutable() 安全查找二进制;设备路径和介质类型均做了输入校验。


💡 改进建议代码示例

// 更精确的设备路径校验
static const QRegularExpression devPattern("^/dev/sr[0-9]+$");
if (!devPattern.match(cleanDev).hasMatch()) {
    qWarning() << "[dfm-burn] Invalid device path:" << dev;
    Q_EMIT jobStatusChanged(JobStatus::kFailed, -1);
    return false;
}

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

@liyigang1

Copy link
Copy Markdown
Contributor Author

返工撤销:负责人审核要求撤销 develop/eagle 分支提交,此 PR 关闭。

@liyigang1 liyigang1 closed this Sep 23, 2026
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