aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-05-21 23:18:57 -0400
committerJesse Luehrs <doy@tozt.net>2020-05-21 23:40:44 -0400
commit41123157c6d356006af12425863f003a4dc87f3d (patch)
tree45e4876c14ebf1ed6d1887ca49b8e82d6e9150e6
parentaed6ea86358e25206023b8ac95f10a823a44e529 (diff)
downloadrbw-41123157c6d356006af12425863f003a4dc87f3d.tar.gz
rbw-41123157c6d356006af12425863f003a4dc87f3d.zip
don't pretend that the version is 0 if the version command fails
this was intended to paper over agents that didn't recognize the version command, but they almost certainly don't exist at this point and it makes the error messages super confusing
-rw-r--r--src/bin/rbw/commands.rs18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index b9be09b..2934de3 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -791,15 +791,11 @@ fn ensure_agent() -> anyhow::Result<()> {
rbw::protocol::VERSION,
version
);
- if version != 0 {
- crate::actions::quit()?;
- }
+ crate::actions::quit()?;
ensure_agent_once()?;
let version = version_or_quit()?;
if version != rbw::protocol::VERSION {
- if version != 0 {
- crate::actions::quit()?;
- }
+ crate::actions::quit()?;
return Err(anyhow::anyhow!(
"incompatible protocol versions: client ({}), agent ({})",
rbw::protocol::VERSION,
@@ -834,13 +830,9 @@ fn ensure_agent_once() -> anyhow::Result<()> {
}
fn version_or_quit() -> anyhow::Result<u32> {
- Ok(match crate::actions::version() {
- Ok(version) => version,
- Err(e) => {
- log::warn!("{}", e);
- crate::actions::quit()?;
- 0
- }
+ crate::actions::version().or_else(|e| {
+ let _ = crate::actions::quit();
+ Err(e)
})
}