From 2a4316f4a256012120337064df150944880b6453 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 9 Nov 2026 22:25:53 +0000 Subject: document file: undo the clean stop's mark before deciding the actor At start, a node on a document file appends an Opened record before it writes anything, so that a Closed record before it no longer says the file holds every change of the actor it names. It does so now before deciding which actor to write as, and DocumentFile::open says whether it could: where the append fails (the disk full, permissions), the file still ends with Closed, and later appends likely fail too. A crash, or a clean stop whose last append failed (close then sees the file behind and writes no mark), would leave that Closed standing for a run the file never got. So with --keep-actor, the node writes on as the actor of before only where the file was marked as opened; else it writes as a fresh actor and warns. --- src/document/file.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/document/file.rs') diff --git a/src/document/file.rs b/src/document/file.rs index 56114f5..1a33918 100644 --- a/src/document/file.rs +++ b/src/document/file.rs @@ -399,16 +399,22 @@ impl DocumentFile { /// Marks the file as opened (`Record::Opened`), at start, before the node writes: /// a `Closed` before it no longer says the file holds everything (a crash from here - /// on leaves it without one). Nothing where there is no file yet. - pub(crate) fn open(&self) { + /// on leaves it without one). Nothing where there is no file yet. Whether the file + /// now ends without a `Closed`: where the mark couldn't be appended, it still says + /// the run of before stopped cleanly, and the node must not write on as its actor. + pub(crate) fn open(&self) -> bool { if !self.path.exists() { - return; + return true; } - if let Err(error) = - self.files - .append(FileKind::Document, &self.path, &record(Record::Opened, &[])) + match self + .files + .append(FileKind::Document, &self.path, &record(Record::Opened, &[])) { - error!(path = %self.path.display(), error = %error, "Couldn't mark the document file as opened"); + Ok(()) => true, + Err(error) => { + error!(path = %self.path.display(), error = %error, "Couldn't mark the document file as opened"); + false + } } } -- cgit v1.3.1