diff options
Diffstat (limited to 'src/bin/rbw/commands.rs')
-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, |