From 8a81e826f0ec61eab9737ca443197865324b52bd Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 2 May 2020 19:03:01 -0400 Subject: tell the agent to quit if the version command errors this should allow more seamless upgrades from the previous version --- src/bin/rbw/commands.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/bin/rbw/commands.rs') diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index b29987d..e05f2eb 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -494,18 +494,22 @@ pub fn stop_agent() -> anyhow::Result<()> { fn ensure_agent() -> anyhow::Result<()> { ensure_agent_once()?; - let version = crate::actions::version()?; + let version = version_or_quit()?; if version != rbw::protocol::VERSION { log::debug!( "client protocol version is {} but agent protocol version is {}", rbw::protocol::VERSION, version ); - crate::actions::quit()?; + if version != 0 { + crate::actions::quit()?; + } ensure_agent_once()?; - let version = crate::actions::version()?; + let version = version_or_quit()?; if version != rbw::protocol::VERSION { - crate::actions::quit()?; + if version != 0 { + crate::actions::quit()?; + } return Err(anyhow::anyhow!( "incompatible protocol versions: client ({}), agent ({})", rbw::protocol::VERSION, @@ -539,6 +543,17 @@ fn ensure_agent_once() -> anyhow::Result<()> { Ok(()) } +fn version_or_quit() -> anyhow::Result { + Ok(match crate::actions::version() { + Ok(version) => version, + Err(e) => { + log::warn!("{}", e); + crate::actions::quit()?; + 0 + } + }) +} + fn find_entry( db: &rbw::db::Db, name: &str, -- cgit v1.2.3-54-g00ecf