Skip to content

Keep Google Drive document identity tied to the file ID - #1497

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:codex/preserve-google-drive-file-identity
Nov 16, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:codex/preserve-google-drive-file-identity

Conversation

@Maya-Kid

Copy link
Copy Markdown
Contributor

Why

A copied Google Drive file gets a different file ID even when its bytes are unchanged. Syncing the copy currently treats it as a path rename: after a.txt is synced, adding b.txt with the same bytes changes the original document's external key to gdrive://b and leaves gdrive://a unbound.

What changes

Key Drive sync only by its stable file ID. A different ID with the same content remains a duplicate under the existing per-base content rule, including when the original is temporarily outside the selected folders. If the copy later has different content it gets its own document. Path-based sources and the explicit API tombstone-and-rekey behavior keep their existing rules.

How it was checked

Validation on Linux x86_64, Rust 1.98.1, PostgreSQL 16 with the production schema:

  • Mock Drive HTTP + real PostgreSQL, driving the production sync loop: the regression against f33f9fc9 failed because the original UUID now had key gdrive://b and filename b.txt. The same test passed at 812b7e50 and checks the original UUID, key, name and version history, independent import of the edited copy, and a same-content duplicate after the original becomes missing.
  • Fresh isolated schema with PostgreSQL 16.15 client tools; all 1,848 workspace tests passed, with six existing ignored. Database and Poppler tests were required. The existing API tests still pass for same-ID update, explicit tombstone rekey, and duplicate content. Workspace build passed.
  • cargo fmt --all --check, git diff --check, and Linux cargo clippy --workspace --all-targets -- -D warnings passed.

Before review

  • The commit is signed off.
  • Workspace formatting, Clippy, and tests passed.

Signed-off-by: Maya Kid <BinjunYann@gmail.com>

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is correct for Drive. Notion (notion://{id}, where a duplicated page has identical text) and the custom endpoint (custom:{id}) are also keyed by a stable ID and still go through Identity::Path, so they have the same rekey bug — a follow-up moving them to StableId would be welcome. Merging.

@WaylandYang
WaylandYang merged commit e160214 into deeplethe:dev Nov 16, 2026
6 checks passed
@Maya-Kid
Maya-Kid deleted the codex/preserve-google-drive-file-identity branch November 29, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants