fix(sync): (Codex) Google Drive ensureDirExists() 接口语义不一致#1391
Open
cyfung1031 wants to merge 1 commit intomainfrom
Open
fix(sync): (Codex) Google Drive ensureDirExists() 接口语义不一致#1391cyfung1031 wants to merge 1 commit intomainfrom
ensureDirExists() 接口语义不一致#1391cyfung1031 wants to merge 1 commit intomainfrom
Conversation
ensureDirExists() 接口语义不一致ensureDirExists() 接口语义不一致
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.
原本
ensureDirExists(dirPath)名字表示“确保目录存在”,但实际只做查找;目录不存在就抛错。现在改成真正逐级确保目录存在,并返回最终目录 ID。createDir()和ensureDirExists()现在共用同一套内部逻辑ensureDirPath()ensureDirPath()从 Google DriveappDataFolder根目录开始逐级查找目录createFolder()创建,再缓存 IDensureDirExists("/A/B")现在会真的确保/A/B存在,并返回B的 folder id这个修正主要解决 writer 路径问题。
GoogleDriveFileWriter.write()原本依赖ensureDirExists(),但如果上层没先建目录,写入会失败。现在 writer 自己调用ensureDirExists()时,目录缺失也能正确创建。同时避免了一个陷阱:没有让
ensureDirExists()直接调用createDir(),因为在openDir("/Base")后写文件时,直接调用createDir("/Base")可能被拼成重复路径/Base/Base。所以这次抽了 root-based 的内部 helper。测试补在 googledrive.test.ts
ensureDirExists("/A/B")会创建缺失的嵌套目录并返回最终 ID/Base,不会变成重复路径