Repository navigation
fix(webdav): guard tombstone-driven deletes with pre-delete fingerprints - #19
Merged
Merged
Conversation
WebDAV sync safety fixes for deletion propagation. See PR body for details. Bump version to 0.9.100.
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.
问题
WebDAV 同步在删除传播上存在多条会误删用户数据的路径,集中在「移除设备副本 / 删除云端备份 / 墓碑复活 / 瞬时 IO 失败」几个场景的交界处:
deletedAt时间戳,无法区分「删除那一刻就在的同一文件」和「删除后重新导入的同路径文件」,仅靠 mtime 判断会在重新导入后仍把文件当旧文件删掉;fingerprint=null会继续往下走远端删除,一次 stat 失败就把远端备份删掉;deleteAction:'local')只删bookFile、保留书架活条目,但同步引擎把「本地文件缺失」当成「本地已删除」,进而向远端发删除,把还有效的书从云端删掉;upsertRemoteLibraryIndex用 spread 保留了远端条目的旧deletedAt,updatedAt刷新后numericVersion取到旧墓碑值,mergeLibrary回写又把刚上传的书标删;destroy()不执行,preventDefault已拦截默认关闭,窗口卡死在桌面。改动
services/webdav/sync/state.tsWebDavSyncStateEntry.deletedAt注释:墓碑条目现在同时携带删除前的local指纹,供清扫时做「同一文件」判定;旧墓碑没有local→ 无法证明同一文件 → 一律按复活处理(宁留不删)。services/webdav/sync/engine.tsisSameLocalFileAsTombstone:删除是不可逆操作,要求有证据相同才删——两端至少一对可比字段(md5 优先、size 兜底)且相等才判同一文件;指纹不一致或不可比 → 复活。continue(不再落到远端删除);本地已无文件也不再传播远端删除,交给条目循环按下载/上传语义处理;复活判定加入指纹比对。items书目文件条目携带bookDeletedAt(书架活条目为null|undefined,显式删书为number),用'bookDeletedAt' in item区分书目条目与 cover/config/library 条目。localDeletion/bothDeleted/remoteDeletion收窄:书目条目仅当书架条目已显式删除(localEntryDeleted)才成立。「移除设备副本」不再触发远端删除;远端缺失对活条目改为落到上传回补分支而非删本地。markDeleted两个方向都加allowRemoteTombstoneDelete闸门:远端删除和本地删除都要求书架条目已显式删除,墓碑驱动的双向收敛对活条目完全关闭。local指纹,供下轮isSameLocalFileAsTombstone比对。app/library/components/WebDavCenterWindow.tsxupsertRemoteLibraryIndex重新上传时显式丢弃远端条目的deletedAt,避免旧墓碑经numericVersion/mergeLibrary回写把复活的再标删。utils/window.tstauriHandleOnCloseWindow:callback和emitTo失败都 catch 住,destroy()必然执行,修复窗口卡死。package.json0.9.99→0.9.100。删除判定矩阵(书目文件条目)
localDeletion删远端remoteDeletion删本地bothDeleted收敛墓碑tombstoneCleanup删本地cover/config/library 条目无
bookDeletedAt键,isBookFileItem=false,全部保持原判据不变。验证
tsc --noEmit通过eslint改动文件无告警发版
合并到
main后build.yml检测到v0.9.100不存在会自动创建 release 并触发 Windows / Linux / Android 打包。