Skip to content

fix(sync): (Codex) OneDrive zero-byte upload fix#1405

Open
cyfung1031 wants to merge 1 commit intomainfrom
fix/sync/011
Open

fix(sync): (Codex) OneDrive zero-byte upload fix#1405
cyfung1031 wants to merge 1 commit intomainfrom
fix/sync/011

Conversation

@cyfung1031
Copy link
Copy Markdown
Collaborator

问题分析
当前 OneDriveFileWriter.write() 对所有内容都走 createUploadSession,然后生成:

Content-Range: bytes 0-${size - 1}/${size}

当内容为空时,size = 0,会变成非法 header:

Content-Range: bytes 0--1/0

这会导致空脚本、空资源、空元数据上传到 OneDrive 失败。这个问题不依赖 typed error、同步冲突检测或缓存修复。

本地改动
改了 packages/filesystem/onedrive/rw.ts :
size === 0 时,改用 OneDrive simple upload:

PUT /me/drive/special/approot:{path}:/content

非空内容继续使用原来的 upload session 路径,避免扩大行为变更。

补了测试在 packages/filesystem/onedrive/onedrive.test.ts:

  • 空字符串走 simple PUT,不创建 upload session
  • 空 Blob 走 simple PUT
  • 非空内容仍走 upload session
  • 非空 Content-Range 仍为正常值,例如 bytes 0-2/3

@cyfung1031 cyfung1031 changed the title fix(sync): OneDrive zero-byte upload fix fix(sync): (Codex) OneDrive zero-byte upload fix May 6, 2026
@cyfung1031 cyfung1031 added the CloudSync Related to CloudSync label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CloudSync Related to CloudSync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant