Summary
When a nav-listed file is renamed or moved (git mv), incremental sync treats the new path as a create and leaves the old file_rel entry in .notion_sync_state.json. This produces duplicate Notion pages for the same note.
Current behavior
git_diff correctly records rename status (R100\told\tnew):
- Old path →
md_deleted (logged; Notion page untouched)
- New path →
md_changed → sync_one_page creates a new page
State is keyed by file_rel, so the old mapping is never migrated to the new key.
Proposed solution
- On rename entries in git diff, migrate state:
state.pages[old_rel] → state.pages[new_rel] (same Notion id / url).
- Optionally reparent if nav parent changed as part of the move.
- Update content on the existing Notion page instead of creating a new one.
- Log:
renamed state obsidian/old.md → obsidian/new.md.
Also handle renames passed via --paths / CI path lists when old path appears in md_deleted and new in md_changed in the same run.
Acceptance criteria
Related
- Nav hierarchy reconciliation (reparent)
- Opt-in orphan pruning (old path without migration would leave orphan)
Summary
When a nav-listed file is renamed or moved (
git mv), incremental sync treats the new path as a create and leaves the oldfile_relentry in.notion_sync_state.json. This produces duplicate Notion pages for the same note.Current behavior
git_diffcorrectly records rename status (R100\told\tnew):md_deleted(logged; Notion page untouched)md_changed→sync_one_pagecreates a new pageState is keyed by
file_rel, so the old mapping is never migrated to the new key.Proposed solution
state.pages[old_rel]→state.pages[new_rel](same Notionid/url).renamed state obsidian/old.md → obsidian/new.md.Also handle renames passed via
--paths/ CI path lists when old path appears inmd_deletedand new inmd_changedin the same run.Acceptance criteria
git mvof a synced note updates content on the existing Notion page.file_rel.Related