Skip to content

fix(ftp): handle EOF and detect content type from read bytes - #3125

Merged
jyxjjj merged 1 commit into
OpenListTeam:mainfrom
awaae001:fix/ftp_new_fle
Sep 23, 2026
Merged

jyxjjj merged 1 commit into
OpenListTeam:mainfrom
awaae001:fix/ftp_new_fle

Conversation

@awaae001

@awaae001 awaae001 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

当客户端向服务器推送 FTP 空文件的时候,FTP 会读取前 512 字节来判断类型。对于空文件来说,这会提前返回 io.EOF 表示文件结束,但代码将其判断为错误并返回。

这个 PR 让 server/ftp/fsup.go 允许读到 EOF,并只用实际读到的字节判断类型

这是一个小修复

  • This PR has breaking changes.
  • This PR changes public API, config, storage format, or migration behavior.
  • This PR requires corresponding changes in related repositories.

Related Issues / 关联 Issue

[Feature] FTP 功能增强:支持 UI 开关与配置、新增日志记录及修复创建空文件失败问题 - #3087

Testing / 测试

测试环境:CachyOS Linux(Arch 系,x86_64)

  • go test ./...
  • Manual test / 手动测试:

我在修改前的客户端上传了一个空文件,返回 550 Issue during transfer: EOF,文件未生成。

修复后,使用 FTP admin 账号上传 0 字节文件:返回 226,SIZE 为 0,下载内容为 0 字节。

Checklist / 检查清单

  • I have read CONTRIBUTING.
    / 我已阅读 CONTRIBUTING。
  • I confirm this contribution follows the repository license, contribution policy, and code of conduct.
    / 我确认此贡献符合仓库许可证、贡献规范和行为准则。
  • I have formatted the changed code with gofmt, go fmt, or prettier where applicable.
    / 我已按适用情况使用 gofmt、go fmt 或 prettier 格式化变更代码。
  • I have requested review from relevant maintainers or code owners where applicable.
    / 我已在适用情况下请求相关维护者或代码所有者审查。

AI Disclosure / AI 使用声明

本次提交使用 ChatGPT-6-astro-low 辅助生成、测试,我已审查对应的代码并且手动进行相关测试。

  • I have reviewed and validated all AI-assisted content included in this PR.
    / 我已审核并验证此 PR 中的所有 AI 辅助内容。
  • I have ensured that all AI-assisted commits include Co-Authored-By attribution.
    / 我已确保所有 AI 辅助提交都包含 Co-Authored-By 归属信息。
  • I can reproduce all AI-assisted content included in this PR without any AI tools.
    / 我可以在没有任何 AI 工具的情况下重现此 PR 中包含的所有 AI 辅助内容。

@jyxjjj
jyxjjj merged commit 40f4f65 into OpenListTeam:main Sep 23, 2026
13 checks passed
@awaae001
awaae001 deleted the fix/ftp_new_fle branch September 23, 2026 17:27
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