Only run command if file exists

This commit is contained in:
Dániel Buga 2022-09-11 20:16:46 +02:00
parent 3c3f2bfcdc
commit 9565dc148e
1 changed files with 7 additions and 3 deletions

View File

@ -380,6 +380,12 @@ fn flatpak_should_use_host_terminal() -> bool {
const FLATPAK_INFO_PATH: &str = "/.flatpak-info";
// The de-facto way of checking whether one is inside of a Flatpak container is by checking for
// the presence of /.flatpak-info in the filesystem
if !Path::new(FLATPAK_INFO_PATH).exists() {
return false;
}
// Ensure flatpak-spawn --host can execute a basic command
let host_available = Command::new("flatpak-spawn")
.arg("--host")
@ -387,7 +393,5 @@ fn flatpak_should_use_host_terminal() -> bool {
.status()
.unwrap();
// The de-facto way of checking whether one is inside of a Flatpak container is by checking for
// the presence of /.flatpak-info in the filesystem
Path::new(FLATPAK_INFO_PATH).exists() && host_available.success()
host_available.success()
}