fix(storage): atomic task-file writes
write_task used plain fs::write for the .md payload even though every other write path in this module (metadata files, sync state, offline queue, config) uses atomic_write. A crash mid-write left a truncated .md file whose malformed YAML frontmatter then failed list_tasks for the entire list. Route through atomic_write so a failed write either leaves the old file intact or produces the full new file.
This commit is contained in:
parent
a0e2bb214b
commit
604a6058b8
|
|
@ -381,7 +381,9 @@ impl Storage for FileSystemStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = self.write_markdown_with_frontmatter(task)?;
|
let content = self.write_markdown_with_frontmatter(task)?;
|
||||||
fs::write(&task_path, content)?;
|
// Atomic write: a crash mid-write must not leave a truncated .md file
|
||||||
|
// that then fails YAML parsing on the next list_tasks/read_task.
|
||||||
|
atomic_write(&task_path, content.as_bytes())?;
|
||||||
|
|
||||||
// Update list metadata to include this task in task_order if not already present
|
// Update list metadata to include this task in task_order if not already present
|
||||||
let mut list_metadata = self.read_list_metadata(list_id)?;
|
let mut list_metadata = self.read_list_metadata(list_id)?;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue