Skip to content

fix: correct error prompt on disk-full transfer - #838

Draft
pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:release/v20
Draft

pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:release/v20

Conversation

@pppanghu77

@pppanghu77 pppanghu77 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

During file transfer, when the receiver's disk runs out of space mid-write, FSAdapter::writeBlock() returns false but writeAndCreateFile() (transferjob.cpp:715) never sets _device_not_enough. Consequently, handleJobStatus() omits the "::not enough" suffix and the frontend falls back to showing "file read/write error" instead of "insufficient storage". Additionally, the sender's sendToRemote() IO_ERROR path (transferjob.cpp:757) only checks block->flags & JobTransFileOp::FILE_COUNTED, which is never set for data blocks, so _device_not_enough is always false on the sender side too.

Fix Approach

Added errno check for ENOSPC/EFBIG in writeBlock() second overload via an output parameter bool *not_enough; writeAndCreateFile() passes this and sets _device_not_enough when disk-full is detected. Also fixed the first overload of writeBlock() to return false on write failure (previously always returned true), and changed sendToRemote() IO_ERROR path to set _device_not_enough = true unconditionally since IO_ERROR is only returned on remote write failure.

Change Safety Assessment

Code Safety

  • Risk Level: Medium
  • Signature change to writeBlock() second overload uses default parameter (bool *not_enough = nullptr), backward compatible; sole caller writeAndCreateFile() updated accordingly
  • First overload return value fix (true → write) affects no external callers; corrects existing buggy behavior
  • Does not revert historical fix e1e8cd98 (pre-check path unchanged); complements it by covering the write-failure path it missed

Business Impact Scope

File transfer module — affects error prompts when disk space is insufficient during file transfer on both sender and receiver sides. Non-disk-full I/O errors (e.g., permission denied) continue to show "file read/write error" as before.

Verification Suggestion

Test file transfer with receiver disk full (should show "insufficient storage"), with normal space (regression), and with permission-denied write path (should still show "file read/write error").


根因分析

文件传输过程中,接收端磁盘在写入过程中填满时,FSAdapter::writeBlock() 返回 false,但 writeAndCreateFile()(transferjob.cpp:715)未设置 _device_not_enough。因此 handleJobStatus() 不含 "::not enough" 后缀,前端回退显示"文件读写异常"而非"储存空间不足"。此外,发送端 sendToRemote() 的 IO_ERROR 路径(transferjob.cpp:757)仅检查 block->flags & JobTransFileOp::FILE_COUNTED,数据块从不设置该标志,导致发送端 _device_not_enough 始终为 false。

修复方案

在 writeBlock() 第二重载中通过输出参数 bool *not_enough 增加 errno 检查 ENOSPC/EFBIG;writeAndCreateFile() 据此设置 _device_not_enough。同时修复第一重载写入失败仍返回 true 的缺陷,并将 sendToRemote() IO_ERROR 路径改为无条件设置 _device_not_enough = true(IO_ERROR 仅在远端写入失败时返回)。

改动安全评估

代码安全评估

  • 风险等级: 中风险
  • writeBlock() 第二重载签名变更使用默认参数(bool *not_enough = nullptr),向后兼容;唯一调用者 writeAndCreateFile() 已同步更新
  • 第一重载返回值修复(true → write)无外部调用者,纠正既有缺陷行为
  • 不撤销历史修复 e1e8cd98(预检查路径不变),本次仅补全其遗漏的写入失败路径

业务影响范围

文件传输模块——影响发送端和接收端磁盘空间不足时的错误提示。非空间类 I/O 错误(如权限不足)仍显示"文件读写异常",行为不变。

验证建议

测试接收端磁盘满时的文件传输(应显示"储存空间不足")、正常空间下的文件传输(回归验证)、权限不足等非空间类写入错误(应仍显示"文件读写异常")。

Summary by Sourcery

Correct file-transfer error reporting for disk-full conditions on both sides of the transfer.

Bug Fixes:

  • Report insufficient-storage conditions consistently when transfers fail because the sender or receiver lacks disk space.
  • Preserve generic file I/O errors for failures unrelated to available storage.

Enhancements:

  • Propagate disk-capacity failure information through file-transfer responses so clients can display the appropriate error prompt.
  • Correct file block write failure reporting so unsuccessful writes are not reported as successful.

@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: pppanghu77

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 29, 2026

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

Reviewer's Guide

The PR fixes disk-full error reporting across file transfers by detecting ENOSPC/EFBIG during receiver writes, propagating that state into transfer status handling, correcting write failure return values, and consistently marking sender-side remote IO_ERROR responses as insufficient-storage failures.

Sequence diagram for disk-full transfer error propagation

sequenceDiagram
    participant Sender
    participant Receiver as ReceiverTransferJob
    participant FS as FSAdapter
    participant Frontend

    Sender->>Receiver: sendToRemote(block)
    Receiver->>FS: writeBlock(..., &not_enough)
    FS-->>Receiver: false, not_enough = true
    Receiver->>Receiver: _device_not_enough = true
    Receiver-->>Sender: IO_ERROR
    Sender->>Sender: _device_not_enough = true
    Sender->>Frontend: handleJobStatus()
    Frontend-->>Frontend: Show insufficient storage
Loading

File-Level Changes

Change Details Files
Propagate disk-full write failures from the filesystem layer to transfer status handling.
  • Detect ENOSPC and EFBIG through an optional output parameter.
  • Set the transfer job's insufficient-storage flag when block writes fail for those errors.
  • Correct the simpler block-write overload to report failed writes instead of unconditional success.
src/plugins/daemon/core/service/fsadapter.cpp
src/plugins/daemon/core/service/fsadapter.h
src/plugins/daemon/core/service/job/transferjob.cpp
Correct sender-side handling of remote write errors.
  • Treat remote IO_ERROR responses as insufficient-storage failures and preserve the corresponding frontend prompt.
src/plugins/daemon/core/service/job/transferjob.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

1. Root cause: writeBlock() returns false on disk-full but caller
   writeAndCreateFile() never sets _device_not_enough, so
   handleJobStatus() omits "::not enough" suffix and frontend
   shows generic "file read/write error" instead of "insufficient
   storage"
2. Fix: add errno check for ENOSPC/EFBIG in writeBlock() overloads,
   pass result via output parameter; writeAndCreateFile() sets
   _device_not_enough accordingly; fix first overload to return
   false on write failure; fix sendToRemote() IO_ERROR path to
   check not_enough flag from FileTransResponse instead of
   unconditionally setting _device_not_enough
3. Impact: disk-full during file transfer now correctly shows
   "insufficient storage" on both sender and receiver; other I/O
   errors remain showing "file read/write error"

Log: Fix incorrect error prompt when storage space is insufficient during file transfer

Influence:
1. Test file transfer when receiver disk is full
2. Test file transfer with normal available space
3. Test file transfer with permission-denied write path

fix: 修复传输过程中磁盘空间不足时错误提示不正确的问题

1. 根因:writeBlock() 在磁盘空间不足时返回 false,但调用方
   writeAndCreateFile() 未设置 _device_not_enough 标志,
   handleJobStatus() 因此不含 "::not enough" 后缀,前端回退
   显示"文件读写异常"而非"储存空间不足"
2. 方案:在 writeBlock() 重载中增加 errno 检查 ENOSPC/EFBIG,
   通过输出参数传递空间不足信号;writeAndCreateFile() 据此设置
   _device_not_enough;修复第一重载写入失败仍返回 true 的缺陷;
   修复 sendToRemote() IO_ERROR 路径改为检查 FileTransResponse
   中的 not_enough 标志,避免非磁盘满场景误报
3. 影响:磁盘空间不足时正确显示"储存空间不足",其他 I/O 错误
   仍显示"文件读写异常"

Log: 修复文件传输过程中储存空间不足时提示错误的问题

Influence:
1. 测试接收端磁盘空间不足时的文件传输
2. 测试正常可用空间下的文件传输
3. 测试权限不足等非空间类写入错误时的提示

Bug: https://pms.uniontech.com/bug-view-261917.html
PMS: BUG-261917
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