Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
ops/direnv: don’t ignore every connection error
Browse files Browse the repository at this point in the history
We were throwing every single error that could be thrown by a varlink
connection into a single bin, even though only one trivial case would
mean the socket is not reachable.
  • Loading branch information
Profpatsch committed Jun 30, 2020
1 parent 93d9301 commit eafb147
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/ops/direnv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ pub fn main<W: std::io::Write>(project: Project, mut shell_output: W) -> OpResul
let address = crate::ops::get_paths()?.daemon_socket_address();
let shell_nix = rpc::ShellNix::try_from(&project.nix_file).map_err(ExitError::temporary)?;

let ping_sent = if let Ok(connection) = varlink::Connection::with_address(&address) {
use rpc::VarlinkClientInterface;
rpc::VarlinkClient::new(connection)
.watch_shell(shell_nix)
.call()
.is_ok()
} else {
false
let ping_sent = match varlink::Connection::with_address(&address) {
Ok(connection) => {
use rpc::VarlinkClientInterface;
rpc::VarlinkClient::new(connection)
.watch_shell(shell_nix)
.call()
.expect("unable to ping varlink server");
true
}
Err(err) => match err.kind() {
// We cannot connect to the socket
varlink::error::ErrorKind::Io(std::io::ErrorKind::ConnectionRefused) => false,
// Any other error is probably a bug
_ => panic!("failed connecting to socket: {:?}", err),
},
};

match (ping_sent, paths_are_cached) {
Expand Down

0 comments on commit eafb147

Please sign in to comment.