fix(sync): (Codex) 修复 Google Drive 路径 ID 缓存在外部删除后失效的问题 | 前置PR #1406#1407
Open
cyfung1031 wants to merge 1 commit intofix/sync/012from
Open
fix(sync): (Codex) 修复 Google Drive 路径 ID 缓存在外部删除后失效的问题 | 前置PR #1406#1407cyfung1031 wants to merge 1 commit intofix/sync/012from
cyfung1031 wants to merge 1 commit intofix/sync/012from
Conversation
Member
|
怎么还在处理这块,有点害怕了 AI 总是会找出新问题的 |
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.
标题
修复 Google Drive 路径 ID 缓存在外部删除后失效的问题
概述
本 PR 修复 Google Drive path-to-ID cache 在远端目录被外部删除后可能继续使用 stale ID 的问题。
主要改动:
clearPathCache(path?),用于清理 Google Drive 的路径到文件 ID 缓存。notFound错误时:list()在当前目录缓存 ID 失效并触发 typednotFound时:clearPathCache(path)。背景
Google Drive 文件系统会缓存路径到 Google Drive file ID 的映射,例如:
如果用户在 Google Drive 网页端或其他客户端删除了这些目录,本地缓存仍可能指向旧 ID。后续上传或列表请求会继续使用 stale parent ID,导致 Google Drive 返回 404。
在本 PR 之前,遇到这种情况时同步流程会失败,而不是清理缓存并重新发现或重建目录。
行为变化
Writer 写入
当 Google Drive writer 在以下阶段遇到 typed
notFound错误时,会清空 path cache 并重试一次:重试时会重新解析目录路径。如果目录确实被外部删除,writer 会按原有逻辑重新创建缺失目录并继续上传。
List 列表
当
list()使用缓存目录 ID 发起列表请求并遇到 typednotFound时,会清空 path cache 并重试一次。如果清空缓存后仍找不到目录,则继续按现有行为抛出目录不存在错误。
不改变的行为
notFound错误下重试。实现说明
本 PR 在 404 后选择清空整个 Google Drive path cache,而不是只清理当前路径。
原因是 stale ID 可能来自上级目录。例如当前路径是:
但真正失效的是:
如果只清理
/Base/Sub,重试时仍会命中 stale/Base,导致再次失败。清空整个 cache 只发生在 provider 明确返回 404 后,避免常规路径增加额外开销。需要先合并 #1406