Amethyst now checks for .pacnew and .pacsave files and prompts the user to run pacdiff if necessary

i18n
Michal 2 years ago
parent 92b7829fe1
commit ab5e337012

@ -28,6 +28,10 @@ impl ShellCommand {
} }
} }
pub fn pacdiff() -> Self {
Self::new("pacdiff")
}
pub fn makepkg() -> Self { pub fn makepkg() -> Self {
Self::new("makepkg") Self::new("makepkg")
} }

@ -1,9 +1,26 @@
use crate::internal::strings::info; use crate::internal::strings::prompt;
use crate::internal::error::SilentUnwrap;
use crate::internal::exit_code::AppExitCode;
use crate::internal::commands::ShellCommand;
pub fn detect(a: String) { pub fn detect() {
if a.contains(".pacnew") || a.contains(".new") { let mut pacnew = vec![];
info("It appears that a program you have installed / upgraded has installed a .new/.pacnew config file. Please read over the pacman output and act on it accordingly".to_string());
} else if a.contains(".old") { for entry in std::fs::read_dir("/etc").unwrap() {
info("It appears that a program you have installed / upgraded has installed a .old config file. Please read over the pacman output and act on it accordingly".to_string()); let entry = entry.unwrap();
let path = entry.path();
if path.to_str().unwrap().contains(".pacnew") || path.to_str().unwrap().contains(".pacsave") {
pacnew.push(path);
}
}
if !pacnew.is_empty() {
let choice = prompt("It appears that at least one program you have installed / upgraded has installed a .pacnew/.pacsave config file. Would you like to run pacdiff to deal with this?".to_string(), true);
if choice {
ShellCommand::pacdiff()
.elevated()
.wait()
.silent_unwrap(AppExitCode::PacmanError);
}
} }
} }

@ -7,12 +7,14 @@ pub mod rpc;
mod sort; mod sort;
mod strings; mod strings;
pub mod structs; pub mod structs;
mod detect;
pub use clean::*; pub use clean::*;
pub use initialise::*; pub use initialise::*;
pub use sort::*; pub use sort::*;
use std::env; use std::env;
pub use strings::*; pub use strings::*;
pub use detect::*;
#[macro_export] #[macro_export]
macro_rules! uwu { macro_rules! uwu {

@ -8,6 +8,7 @@ use internal::error::SilentUnwrap;
use crate::internal::exit_code::AppExitCode; use crate::internal::exit_code::AppExitCode;
#[allow(unused_imports)] #[allow(unused_imports)]
use crate::internal::{crash, info, init, log, prompt, sort, structs::Options, warn}; use crate::internal::{crash, info, init, log, prompt, sort, structs::Options, warn};
use crate::internal::detect;
#[global_allocator] #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
@ -49,6 +50,8 @@ fn main() {
operations::clean(options); operations::clean(options);
} }
} }
detect();
} }
fn cmd_install(args: InstallArgs, options: Options) { fn cmd_install(args: InstallArgs, options: Options) {

Loading…
Cancel
Save