Check if the snapd socket exists before trying to run it (fixes #56)
This commit is contained in:
22
src/linux.rs
22
src/linux.rs
@@ -201,19 +201,21 @@ pub fn run_flatpak(terminal: &mut Terminal) -> Option<(&'static str, bool)> {
|
|||||||
pub fn run_snap(sudo: &Option<PathBuf>, terminal: &mut Terminal) -> Option<(&'static str, bool)> {
|
pub fn run_snap(sudo: &Option<PathBuf>, terminal: &mut Terminal) -> Option<(&'static str, bool)> {
|
||||||
if let Some(sudo) = sudo {
|
if let Some(sudo) = sudo {
|
||||||
if let Some(snap) = which("snap") {
|
if let Some(snap) = which("snap") {
|
||||||
terminal.print_separator("snap");
|
if PathBuf::from("/var/snapd.socket").exists() {
|
||||||
|
terminal.print_separator("snap");
|
||||||
|
|
||||||
let success = || -> Result<(), failure::Error> {
|
let success = || -> Result<(), failure::Error> {
|
||||||
Command::new(&sudo)
|
Command::new(&sudo)
|
||||||
.args(&[snap.to_str().unwrap(), "refresh"])
|
.args(&[snap.to_str().unwrap(), "refresh"])
|
||||||
.spawn()?
|
.spawn()?
|
||||||
.wait()?
|
.wait()?
|
||||||
.check()?;
|
.check()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}().is_ok();
|
}().is_ok();
|
||||||
|
|
||||||
return Some(("snap", success));
|
return Some(("snap", success));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user