Fix cloud sync state consistency and provider-safe conflict handling#1504
Open
cyfung1031 wants to merge 73 commits into
Open
Fix cloud sync state consistency and provider-safe conflict handling#1504cyfung1031 wants to merge 73 commits into
cyfung1031 wants to merge 73 commits into
Conversation
Collaborator
Author
Member
|
二次 review 后,我认为目前还不能说云同步场景已经完整覆盖。下面按场景整理“期望行为 / 当前覆盖状态 / 还需要补什么”,方便逐项对照。 总体结论同步层的本地逻辑方向是合理的:按文件 best-effort 同步、失败文件保留旧 digest、成功文件推进 digest、status 写回前合并远端较新状态,这些设计目标是对的。 但当前 PR 还存在关键缺口:provider capability / 条件写删没有真正完整落地,也没有足够测试覆盖。所以现在最多只能证明同步层决策在 mock / 内存 provider 下成立,不能证明真实 WebDAV / S3 / OneDrive 等 provider 上能防止并发覆盖。 云同步场景覆盖矩阵
当前可以说“已覆盖”的范围
当前不能说“已覆盖”的范围
建议最低合格标准
|
Member
|
🤔 看起来没大问题了,但是还是留下一个版本吧 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

背景
本 PR 对 ScriptCat 云同步做一轮生产兼容方向的修复。目标不是把 PR #1439 原样搬进来,而是在现有
main同步语义上修复状态污染、错误吞掉、provider 能力不清晰和条件写入缺失的问题。核心原则:
file_digest,失败文件保留旧 digest,下轮重试。.user.js、旧.meta.json、旧file_digeststring map、缺字段scriptcat-sync.json。总体改动
本 PR 改动集中在 5 类:
scriptcat-sync.json合并写和旧格式兼容涉及文件:
src/app/service/service_worker/synchronize.tssrc/app/service/service_worker/synchronize.test.tspackages/filesystem/**docs/README.md关键行为变化
同步层
pullScript()真实失败不再被静默吞掉。deleteCloudScript()删除失败、tombstone 写失败不再被当作成功。syncOnceInternal()保持 per-file best-effort,单个文件失败不会阻塞其他文件。file_digest。scriptcat-sync.json写回前重新读取远端最新状态并合并,降低覆盖其他设备状态的风险。.user.jswithout.meta.json会跳过,并保留远端 status。scriptInstall/scriptsDelete队列路径的 typed failure 能被分类记录,不污染 digest。filesystem 能力
新增最小 provider capabilities:
同步层只在 provider 显式声明能力时传条件参数:
这样 WebDAV / S3 / OneDrive 可以使用原生条件写删,Google Drive / Dropbox / Baidu 继续保持非 atomic 行为,不伪造 CAS。
provider typed error
已补关键 provider 错误分类:
PreconditionFailed/ 429 / 5xxResponse404 / 409 / 412 / 429Response404 / 409 / 412 / 429,reader path lookup miss typed notFoundpath_lookup/pathnot_found / conflict,raw read 429,保留content_hashopaque digestretry 策略
LimiterFileSystem只重试:verify/open/read/openDir/list/getDirUrlexpectedDigest/createOnlyexpectedDigest普通
write/delete/create不重试,避免非幂等写重复创建或覆盖。Commit 说明
docs(sync): document cloud sync correctness designtest(sync): cover failed task digest preservationfix(sync): preserve failed task digeststest(sync): cover status merge before writescriptcat-sync.jsonfix(sync): merge latest status before writescriptcat-sync.json写回前重新读取并合并test(sync): cover status sync best efforttest(sync): cover legacy sync status filescriptcat-sync.json兼容测试fix(sync): tolerate legacy sync status filetest(sync): cover status write failure isolation193a5ac7 fix(sync): isolate status file write failuresscriptcat-sync.json写失败test(sync): cover corrupt status file isolationfix(sync): isolate unreadable status filetest(fs): cover dropbox typed errorsfix(fs): use typed dropbox errorstest(fs): cover baidu errno classificationfix(fs): classify baidu errno preciselytest(fs): cover raw response typed errorsnothen=true路径fix(fs): type raw provider response errorstest(fs): cover typed transient retriesfix(fs): retry typed transient errorstest(sync): cover delete notification throttlingfix(sync): throttle delete notificationstest(fs): cover filesystem capabilitiesfix(fs): expose filesystem capabilitiestest(fs): cover dropbox raw read errorsfix(fs): type dropbox raw read errorstest(fs): cover s3 transient errorsfix(fs): type s3 transient errorstest(fs): cover webdav transient errorsfix(fs): type webdav transient errorstest(fs): cover s3 conditional operationsfix(fs): support s3 conditional operationstest(fs): cover webdav conditional operationsfix(fs): support webdav conditional operationstest(fs): cover onedrive conditional operationsfix(fs): support onedrive conditional operationstest(sync): cover conditional push optionsfix(sync): use provider conditional writes when safetest(sync): cover conditional cloud deletefix(sync): use provider conditional delete when safetest(fs): cover webdav create-only conflictfix(fs): type webdav create-only conflicttest(sync): cover status write after file failurefix(sync): preserve failed script status while syncing otherstest(fs): cover s3 conditional conflictsdocs(sync): update implemented provider statustest(sync): cover conflict error classificationfix(sync): classify per-file sync failurestest(fs): cover conditional write retryfix(fs): retry protected conditional writesdocs(sync): reflect protected write retrytest(sync): cover sync error kind mappingtest(sync): cover install push transient failurefix(sync): classify queued sync failuresdocs(sync): record queued failure classification auditdocs(sync): refine remaining rollout plantest(sync): cover queued delete typed failurestest(fs): cover dropbox opaque digestdocs(sync): document manual verification pathfix(fs): classify dropbox structured not founderror_summary的 Dropbox 响应test(fs): cover dropbox structured conflictdocs(sync): keep rollout checklist currenttest(fs): cover non-atomic provider capabilitiesdocs(sync): record non-atomic provider coveragefix(sync/fs): address remaining provider verification gapsdocs(sync): record provider gap closuredocs(sync): record manual verification resultdocs(sync): record real provider verificationfix(sync/fs): address real provider verification findingsdocs(sync): finalize rollout status生产兼容性
本 PR 不要求用户手动迁移云端数据。
兼容旧数据:
.user.js/.meta.json可继续读取。file_digeststring map 可继续读取。scriptcat-sync.json缺字段时不会崩溃。.user.jswithout.meta.json会跳过并保留 status。风险和暂不实现项
仍需真实 provider 验证:
filemetas缺失、errno 分类和覆盖写行为。本轮暂不实现:
tombstone_digest。