summaryrefslogtreecommitdiffstats
path: root/src/removable_devices.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-10-26 21:46:11 +0200
committerqkzk <qu3nt1n@gmail.com>2023-10-26 21:46:11 +0200
commit189943723257a15f1a21fad66f45e7cf57a3147e (patch)
tree9e0ffa1dda5dd02cd3094360483bf31d96729ec5 /src/removable_devices.rs
parentc801ba97f631f89c7b17f3aab9021e2854440310 (diff)
improve gio parsing
Diffstat (limited to 'src/removable_devices.rs')
-rw-r--r--src/removable_devices.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/removable_devices.rs b/src/removable_devices.rs
index 27bd270..323bac1 100644
--- a/src/removable_devices.rs
+++ b/src/removable_devices.rs
@@ -1,6 +1,10 @@
use anyhow::{anyhow, Result};
-use crate::{constant_strings_paths::GIO, impl_selectable_content, utils::is_dir_empty};
+use crate::{
+ constant_strings_paths::GIO,
+ impl_selectable_content,
+ utils::{is_dir_empty, is_program_in_path},
+};
/// Holds info about removable devices.
/// We can navigate this struct.
@@ -20,6 +24,9 @@ impl RemovableDevices {
/// Then we create a `Removable` instance for every line.
/// If no line match or if any error happens, we return `None`.
pub fn from_gio() -> Option<Self> {
+ if !is_program_in_path(GIO) {
+ return None;
+ }
let Ok(output) = std::process::Command::new(GIO)
.args(["mount", "-li"])
.output()
@@ -99,6 +106,8 @@ impl Removable {
}
self.is_mounted = std::process::Command::new(GIO)
.args(vec!["mount", &self.format_for_gio()])
+ .stdout(std::process::Stdio::null())
+ .stderr(std::process::Stdio::null())
.spawn()?
.wait()?
.success();
@@ -121,6 +130,8 @@ impl Removable {
}
self.is_mounted = !std::process::Command::new(GIO)
.args(vec!["mount", &self.format_for_gio(), "-u"])
+ .stdout(std::process::Stdio::null())
+ .stderr(std::process::Stdio::null())
.spawn()?
.wait()?
.success();