fix(stream): allow seeking beyond file size per Go convention#2667
Open
Ovear wants to merge 3 commits into
Open
fix(stream): allow seeking beyond file size per Go convention#2667Ovear wants to merge 3 commits into
Ovear wants to merge 3 commits into
Conversation
Remove `offset > size` guard from RangeReadReadAtSeeker.Seek and DynamicReadAtSeeker.Seek. Go's io.Seeker convention allows seeking past EOF.
PIKACHUIM
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 摘要
Go的Seek函数实现(POSIX)允许Seek到超出文件大小的位置,后续由Read返回EOF,部分类库,如
sftpd-openlist依赖这个行为。在Filezilla客户端中使用sftp下载时,当前行为会导致文件无法下载,原因是
Seek返回的错误透传给客户端,而不是sftp规范中的返回EOF,导致客户端认为传输失败。OpenList 错误日志
FileZilla 错误日志
追踪: Processing SSH_MSG_CHANNEL_DATA, channel=0, size=25 追踪: Sending SSH_MSG_CHANNEL_DATA (for 27 bytes), seq=26 追踪: sftp_base::on_read 追踪: Processing SSH_FXP_STATUS, id=12, len=17 追踪: Got status SSH_FX_FAILURE 错误: Could not read from remote file: 收到错误 SSH_FX_FAILURE,没有进一步描述Remove
offset > sizeguard from RangeReadReadAtSeeker.Seek and DynamicReadAtSeeker.Seek. Go's io.Seeker convention allows seeking past EOF./ 此 PR 包含破坏性变更。
/ 此 PR 修改了公开 API、配置、存储格式或迁移行为。
/ 此 PR 需要关联仓库同步修改。
Testing / 测试
go test ./...Checklist / 检查清单
/ 我已阅读 CONTRIBUTING。
/ 我确认此贡献符合仓库许可证、贡献规范和行为准则。
gofmt,go fmt, orprettierwhere applicable./ 我已按适用情况使用
gofmt、go fmt或prettier格式化变更代码。/ 我已在适用情况下请求相关维护者或代码所有者审查。