aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw/commands.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-05-02 19:03:01 -0400
committerJesse Luehrs <doy@tozt.net>2020-05-02 19:03:01 -0400
commit8a81e826f0ec61eab9737ca443197865324b52bd (patch)
treed41973edb6dca1d76baf497206b45df6a4fc0190 /src/bin/rbw/commands.rs
parent737b57922e8230d031a55e81bc01de44cbe278bb (diff)
downloadrbw-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/rbw/commands.rs')
-rw-r--r--src/bin/rbw/commands.rs23
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,