Repository navigation
fix(storage): roll back runtime cache when file write fails - #983
Merged
Merged
Conversation
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.
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.
persistOrRestorehelper: snapshots the fields changed before the write and restores them if the write throws, then rethrows.saveStateand search index updates stay outside the rollback, since the file is already written at that point.update_note/update_snippet: a content-only write failure now returnsSTORAGE_ERRORinstead ofPARTIAL_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.