aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs
index 7c819e5..d8704a0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -184,13 +184,30 @@ async fn main() -> Result<()> {
None => (Document::new(), None, None, Vec::new(), Vec::new(), None),
};
let mut initial_doc = initial_doc;
+ let document_file = args.document_file.clone().map(|path| {
+ Arc::new(document::file::DocumentFile::new(
+ path,
+ Arc::clone(&files),
+ args.document_append,
+ args.document_rewrite,
+ ))
+ });
+ // A clean stop's mark undone before anything is written, and before deciding the
+ // actor: a crash from here on leaves a file that doesn't say so. A file that still
+ // says so (the mark not undone) gets a fresh actor.
+ let opened = document_file.as_ref().is_none_or(|file| file.open());
// Writing on as the actor of before, where this node stopped cleanly: everything it
// wrote as that one is in the document, so no change of it comes twice.
- match resumable.filter(|_| args.keep_actor) {
+ match resumable.filter(|_| args.keep_actor && opened) {
Some(actor) => {
info!(actor = %actor, "Writing on as the actor of before (--keep-actor)");
initial_doc.set_actor(actor);
}
+ None if args.keep_actor && !opened => {
+ warn!(
+ "Writing as a fresh actor: the document file couldn't be marked as opened (--keep-actor)"
+ );
+ }
None if args.keep_actor && starting_epoch.is_some() => {
info!("Writing as a fresh actor: this node didn't stop cleanly (--keep-actor)");
}
@@ -239,19 +256,6 @@ async fn main() -> Result<()> {
let mut transports = transports.into_iter();
let (scheme, transport) = transports.next().context("No transports")?;
- let document_file = args.document_file.clone().map(|path| {
- Arc::new(document::file::DocumentFile::new(
- path,
- Arc::clone(&files),
- args.document_append,
- args.document_rewrite,
- ))
- });
- // A clean stop's mark undone before anything is written: a crash from here on
- // leaves a file that doesn't say so.
- if let Some(file) = &document_file {
- file.open();
- }
let node = node::Node::new(node::NodeConfig {
transport,
identity: Some(transport::identity::IdentityConfig {