Skip to content

fix: "failed to upload2C" - #9612

Open
puffer614 wants to merge 1 commit into
AlistGo:mainfrom
puffer614:main
Open

fix: "failed to upload2C"#9612
puffer614 wants to merge 1 commit into
AlistGo:mainfrom
puffer614:main

Conversation

@puffer614

Copy link
Copy Markdown

fix #9610
如果创建空文件,大多网盘都会报错400。如果是空文件就添加一个占位符,就能正常创建文件。有些挂载软件会先创建一个空文件导致创建文件时报错。
修复无法创建空文件的问题,和部分webdav挂载工具(raidrive 1.8.0,windows自带添加网络位置挂载webdav)无法创建文件的问题。

@puffer614 puffer614 changed the title Add placeholders to empty files and fix the error "failed to upload 2… fix: "failed to upload2C" Aug 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to fix WebDAV file creation failures for certain clients (notably Windows built-in WebDAV mapping and some mounting tools) by addressing backend errors when creating 0-byte files.

Changes:

  • Add a workaround in WebDAV PUT handling to avoid backend failures when uploading empty files.
  • Introduce additional request-body handling for Content-Length: 0 uploads.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread server/webdav/webdav.go
@okatu-loli

Copy link
Copy Markdown
Collaborator

理解你想解决的问题,不过这个改法我有点顾虑。

现在的逻辑会把所有 0 字节的上传都变成 1 字节的 \n 文件,而且是对所有后端生效——本地、S3、FTP 这些本来能好好存空文件的也一起被改了。空文件其实挺常见的(.gitkeep、锁文件、touch 出来的占位文件),这么一改它们的大小和内容就都不对了,还不报错,用户基本发现不了。相当于拿一个能看见的 400,换了一个看不见的数据损坏,我觉得不太划算。

另外这里只判断了 ContentLength == 0,而 #9606 说的其实是 Content-Length 头缺失(值是 -1)的情况,这个 PR 并没覆盖到,所以链接的那个场景没真正修到。

建议换个思路:在具体那个会报 400 的云盘驱动里处理,只对它补占位符,并且把上报的大小改回 0;或者做成一个可选开关。通用的 WebDAV handler 这层影响面太大了,不太适合动。你看要不要往这个方向调一版?

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.

适配windows自带的映射网络驱动器挂载webdav

5 participants