Skip to content

fix(sync): (Codex) 为云同步上传补充 modifiedDate (写入 S3 自定义元数据)#1408

Open
cyfung1031 wants to merge 2 commits intomainfrom
fix/sync/014
Open

fix(sync): (Codex) 为云同步上传补充 modifiedDate (写入 S3 自定义元数据)#1408
cyfung1031 wants to merge 2 commits intomainfrom
fix/sync/014

Conversation

@cyfung1031
Copy link
Copy Markdown
Collaborator

@cyfung1031 cyfung1031 commented May 6, 2026

背景

S3 writer 已经支持 FileCreateOptions.modifiedDate,并会将该时间写入 S3 自定义元数据。但 cloud sync 的上传路径此前没有传递 modifiedDate,导致脚本文件、meta 文件、同步状态文件以及删除 tombstone 在 S3 场景下无法写入对应的时间元数据。

本 PR 补齐 cloud sync 到 filesystem writer 的时间传递,让现有 S3 元数据写入能力在同步上传路径中生效。

改动内容

  • 上传脚本 .user.js 时传入脚本文件时间。
  • 上传脚本 .meta.json 时使用与 .user.js 相同的脚本文件时间。
  • 写入 scriptcat-sync.json 时传入当前同步状态写入时间。
  • 写入删除 tombstone .meta.json 时传入当前删除标记写入时间。
  • 抽出 getScriptModifiedDate(),集中脚本文件时间选择逻辑:
    • 优先使用 script.updatetime
    • 其次使用 script.createtime
    • 最后 fallback 到 Date.now()
  • 为 S3 writer 的 x-amz-meta-createtime 写入补充兼容性注释,说明该字段实际来源是 FileCreateOptions.modifiedDate
  • 补充同步层与 S3 writer 测试,验证 modifiedDate 会被正确传递和写入。

设计说明

.user.js.meta.json 描述的是同一个脚本实体,同步比较也基于脚本更新时间,因此两者使用同一个 modifiedDate 更稳定。

scriptcat-sync.json 表示本次同步状态写入,删除 tombstone 表示本次删除标记写入,因此两者使用写入当下的时间。

S3 侧本次继续写入历史兼容字段 x-amz-meta-createtime,不改为 x-amz-meta-modifiedtime。直接改名可能影响已有对象或旧客户端;如果后续需要让 S3 metadata 参与同步判断,应另开 PR 设计读取策略、双写迁移和兼容逻辑。

非目标

  • 不改变 cloud sync 的同步比较逻辑。
  • 不引入 x-amz-meta-modifiedtime
  • 不设计 S3 metadata 的读取和迁移策略。
  • 不改动其他 filesystem 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
@cyfung1031 cyfung1031 changed the title fix(sync): (Codex) 让云同步上传传递 modifiedDate 以启用 S3 元数据写入 fix(sync): (Codex) 为云同步上传补充 modifiedDate (写入 S3 自定义元数据) May 7, 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