Repository navigation
fix: correct error prompt on disk-full transfer - #838
pppanghu77 wants to merge 1 commit into
Conversation
|
Skipping CI for Draft Pull Request. |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe 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 propagationsequenceDiagram
participant Sender
participant Receiver as ReceiverTransferJob
participant FS as FSAdapter
participant Frontend
Sender->>Receiver: sendToRemote(block)
Receiver->>FS: writeBlock(..., ¬_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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
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
d3cd060 to
4cbe398
Compare
Root Cause Analysis
During file transfer, when the receiver's disk runs out of space mid-write,
FSAdapter::writeBlock()returnsfalsebutwriteAndCreateFile()(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'ssendToRemote()IO_ERROR path (transferjob.cpp:757) only checksblock->flags & JobTransFileOp::FILE_COUNTED, which is never set for data blocks, so_device_not_enoughis alwaysfalseon the sender side too.Fix Approach
Added
errnocheck forENOSPC/EFBIGinwriteBlock()second overload via an output parameterbool *not_enough;writeAndCreateFile()passes this and sets_device_not_enoughwhen disk-full is detected. Also fixed the first overload ofwriteBlock()to returnfalseon write failure (previously always returnedtrue), and changedsendToRemote()IO_ERROR path to set_device_not_enough = trueunconditionally since IO_ERROR is only returned on remote write failure.Change Safety Assessment
Code Safety
writeBlock()second overload uses default parameter (bool *not_enough = nullptr), backward compatible; sole callerwriteAndCreateFile()updated accordinglytrue→write) affects no external callers; corrects existing buggy behaviore1e8cd98(pre-check path unchanged); complements it by covering the write-failure path it missedBusiness 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:
Enhancements: