diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-05-02 19:03:01 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-05-02 19:03:01 -0400 |
commit | 8a81e826f0ec61eab9737ca443197865324b52bd (patch) | |
tree | d41973edb6dca1d76baf497206b45df6a4fc0190 /src/bin | |
parent | 737b57922e8230d031a55e81bc01de44cbe278bb (diff) | |
download | rbw-8a81e826f0ec61eab9737ca443197865324b52bd.tar.gz rbw-8a81e826f0ec61eab9737ca443197865324b52bd.zip |
tell the agent to quit if the version command errors
this should allow more seamless upgrades from the previous version
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/rbw/commands.rs | 23 |
1 files changed, 19 insertions, 4 deletions
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<u32> { + 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, |