From ccad25bdc539cebbfca4fff26ec076f7c25b0339 Mon Sep 17 00:00:00 2001 From: graelo Date: Wed, 21 Sep 2022 09:06:09 +0200 Subject: [PATCH] fix(restore): do not attempt to fetch the new metadata if restoring outside of tmux --- src/actions/restore.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/actions/restore.rs b/src/actions/restore.rs index 75323ce..198b156 100644 --- a/src/actions/restore.rs +++ b/src/actions/restore.rs @@ -92,17 +92,24 @@ pub async fn restore>(backup_filepath: P) -> Result "Attach to your last session with `tmux attach -t {}`", &metadata.client.session_name ); - } else if tmux::server::kill_session("0").await.is_err() { - let message = " + + // Return an overview of the archived tmux environment, which is identical, in principle, + // with the new one. We cannot do more because the client metadata cannot be fetched. + Ok(metadata.overview()) + } else { + if tmux::server::kill_session("0").await.is_err() { + let message = " Unusual start conditions: - you started from outside tmux but no existing session named `0` was found - check the state of your session "; - return Err(Error::ConfigError(message.to_string())); - } + return Err(Error::ConfigError(message.to_string())); + } - let metadata = v1::Metadata::new().await?; - Ok(metadata.overview()) + // Return an overview of the restored tmux environment. + let metadata = v1::Metadata::new().await?; + Ok(metadata.overview()) + } } /// Association between a pane from the backup with a new target pane id.