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

ops/direnv: don’t ignore every connection error #441

Merged
merged 1 commit into from
Jul 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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