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

Commit

Permalink
Merge pull request #441 from target/ops-direnv-check-varlink-errors
Browse files Browse the repository at this point in the history
ops/direnv: don’t ignore every connection error
  • Loading branch information
Profpatsch authored Jul 1, 2020
2 parents 20d6563 + 3a41673 commit 11693cf
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/ops/direnv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ 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::NotFound) => false,
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 11693cf

Please sign in to comment.