Skip to content

fix(storage): roll back runtime cache when file write fails - #983

Merged
antonreshetov merged 1 commit into
mainfrom
fix/rollback-runtime-on-write-failure
Oct 14, 2026
Merged

antonreshetov merged 1 commit into
mainfrom
fix/rollback-runtime-on-write-failure

Conversation

@antonreshetov

Copy link
Copy Markdown
Member

Storage mutated runtime entities before writing the file. If the write failed (EACCES, ENOSPC, etc.), the cache kept the unsaved change: GET, UI and MCP revisions showed it as saved, and the edit was lost on rescan or restart.

  • Add persistOrRestore helper: snapshots the fields changed before the write and restores them if the write throws, then rethrows.
  • Apply it to note body content, note properties, tag add/remove (notes and snippets), and snippet fragment update/create/delete.
  • saveState and search index updates stay outside the rollback, since the file is already written at that point.
  • MCP update_note / update_snippet: a content-only write failure now returns STORAGE_ERROR instead of PARTIAL_UPDATE, and the revision stays unchanged. After a partial update, the returned revision now matches the disk.

updateNote / updateSnippet (rename/move) are not covered: they move files and update the state index before writing, so a field rollback is not enough there.

@antonreshetov antonreshetov self-assigned this Oct 14, 2026
@antonreshetov
antonreshetov merged commit cd8ba43 into main Oct 14, 2026
@antonreshetov
antonreshetov deleted the fix/rollback-runtime-on-write-failure branch October 14, 2026 06:12
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.

1 participant