Skip to content
Snippets Groups Projects
Commit ee2dd78a authored by nfontrod's avatar nfontrod
Browse files

src/mount.rs: change umount_archive to make it silent

parent a66135b0
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,9 @@ pub fn mount_archive(commit: &Option<String>, path: &Option<String>, versions: b
}
/// Unount an borg archive mounted in .mount folder
pub fn umount_archive() -> () {
/// # Argument
/// * silent a boolean indicating if the function fails silently if the archive is not mounted.
pub fn umount_archive(silent: bool) -> () {
let (borg_folder, _) = commit::check_path();
let mount_folder = get_mount_folder(&borg_folder);
let cmd = format!("borg umount {}", mount_folder.to_str().unwrap());
......@@ -59,8 +61,21 @@ pub fn umount_archive() -> () {
match output.status.code().unwrap() {
0 => (),
num => {
eprintln!("{}", String::from_utf8(output.stderr).unwrap());
let mut error_msg = String::from_utf8(output.stderr).unwrap();
let msg = format!(
"fusermount: entry for {} not found in /etc/mtab",
mount_folder.canonicalize().unwrap().to_str().unwrap()
);
if error_msg.ends_with('\n') {
error_msg.pop();
}
match (error_msg == msg) & silent {
true => (),
false => {
eprintln!("{}", error_msg);
exit(num);
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment