pages.rs: fix run of orphans packages
This avoid "error: no targets specified (use -h for help)" when `pacman -Qtdq` is empty. `pacman -Qtdq` can be started without root, and has a return value other than 0 if it finds no packages. So if it finds packages, it succeeds and goes to the true condition that it deletes packages. Otherwise do echo. (echo doesn't require root) Signed-off-by: Peppe289 <gsperanza204@gmail.com>
This commit is contained in:
parent
14ad98637b
commit
280ef70cc8
12
src/pages.rs
12
src/pages.rs
|
@ -65,7 +65,17 @@ fn create_fixes_section() -> gtk::Box {
|
|||
remove_orphans_btn.connect_clicked(move |_| {
|
||||
// Spawn child process in separate thread.
|
||||
std::thread::spawn(move || {
|
||||
let _ = utils::run_cmd_terminal(String::from("pacman -Rns $(pacman -Qtdq)"), true);
|
||||
// check if you have orphans packages.
|
||||
let status = std::process::Command::new("pacman")
|
||||
.arg("-Qtdq")
|
||||
.status()
|
||||
.expect("Found orphans packages");
|
||||
|
||||
if status.success() {
|
||||
let _ = utils::run_cmd_terminal(String::from("pacman -Rns $(pacman -Qtdq)"), true);
|
||||
} else {
|
||||
let _ = utils::run_cmd_terminal(String::from("echo 'Not orphans packages'"), false);
|
||||
}
|
||||
});
|
||||
});
|
||||
clear_pkgcache_btn.connect_clicked(on_clear_pkgcache_btn_clicked);
|
||||
|
|
Loading…
Reference in New Issue