Skip to content

fix(sync): (Codex) 让云同步上传传递 modifiedDate 以启用 S3 元数据写入#1408

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

fix(sync): (Codex) 让云同步上传传递 modifiedDate 以启用 S3 元数据写入#1408
cyfung1031 wants to merge 1 commit intomainfrom
fix/sync/014

Conversation

@cyfung1031
Copy link
Copy Markdown
Collaborator

标题

让云同步上传传递 modifiedDate 以启用 S3 元数据写入

概述

本 PR 让 cloud sync 在创建云端文件时显式传递 modifiedDate,使 S3 writer 现有的 x-amz-meta-createtime 写入能力能被同步上传路径实际使用。

主要改动:

  • pushScript() 上传脚本 .user.js 时传入脚本更新时间。
  • pushScript() 上传 .meta.json 时使用同一个脚本更新时间。
  • 写入 scriptcat-sync.json 时传入当前时间。
  • 写入删除 tombstone .meta.json 时传入当前时间。
  • 补充同步层测试,确认 fs.create() 收到正确的 modifiedDate
  • 补充 S3 writer 测试,确认传入 modifiedDate 后会写入 x-amz-meta-createtime header。

背景

S3 writer 已经支持在 FileCreateOptions.modifiedDate 存在时写入:

x-amz-meta-createtime

但 cloud sync 上传脚本和同步元数据时之前没有传 modifiedDate,导致这条 S3 metadata 写入路径在同步场景下没有被实际使用。

这会让 S3 同步上传缺少更明确的时间元数据,也让已有 writer 能力和 cloud sync 调用之间不一致。

行为变化

脚本上传

pushScript() 现在会计算:

script.updatetime || script.createtime || Date.now()

并作为 modifiedDate 传给:

  • ${uuid}.user.js
  • ${uuid}.meta.json

这样脚本文件和对应 meta 文件会共享同一个脚本时间。

同步状态文件

写入 scriptcat-sync.json 时使用:

Date.now()

作为 modifiedDate

删除标记文件

syncDelete 开启时,写入删除 tombstone .meta.json 使用:

Date.now()

作为 modifiedDate

不改变的行为

本 PR 不实现 S3 list() 的 HEAD metadata 读取。

原因是读取 x-amz-meta-createtime 通常需要对每个对象额外发 HEAD 请求。对大量同步文件来说,这会显著增加请求数和延迟。当前 PR 只补齐上传路径,让已有 metadata 写入能力先被使用;是否在 list 阶段读取 metadata 应作为独立设计处理。

本 PR 也不改变:

  • sync 冲突判断。
  • digest 计算逻辑。
  • 条件写入逻辑。
  • 其他 provider 的上传实现。

@cyfung1031 cyfung1031 changed the title fix(sync): (Codex) cloud sync 写入时传递 modifiedDate,让 S3 metadata 写入路径真正生效 fix(sync): (Codex) 让云同步上传传递 modifiedDate 以启用 S3 元数据写入 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