Skip to content

Recover task contents after a failed vault write - #2715

Open
callumalpass wants to merge 1 commit into
mainfrom
fix/workflows-27-task-write-recovery
Open

callumalpass wants to merge 1 commit into
mainfrom
fix/workflows-27-task-write-recovery

Conversation

@callumalpass

Copy link
Copy Markdown
Owner

Refs callumalpass/tasknotes-workflows#27

Obsidian's desktop process() writes to the live path with fs.promises.writeFile. If the write fails after the file is opened/truncated, the exception can leave an empty task note. Workflows already awaits each item; the underlying macOS timeout trigger is not confirmed.

  • Stage and verify a temporary recovery copy before changing an existing note through the shared frontmatter or content mutation helper. Leave the note alone if the copy cannot be verified or we detect a newer edit before writing.
  • On a failed write, restore only if the target is still empty. Preserve the copy and include its location if the contents cannot be verified as restored or unchanged. Do not retry the task mutation.
  • Cover recovery-write failure, exact content restoration, concurrent edits and an injected ETIMEDOUT on the second item of a batch.

Validation: In isolated Obsidian 1.14.2 on Linux/ext4, the fault injected at the desktop write boundary left a zero-byte note on released TaskNotes 5.0.2. The new build restores the exact contents for reschedule, patch, patch with body and a real Workflows 0.1.6 for-each run. The first note is saved; the third is untouched. Also ran build:test (includes TypeScript) in the disposable vault.

This branch has not been deployed

No deployments
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