diff --git a/src/operations/clean.rs b/src/operations/clean.rs index 936e218..fd8415e 100644 --- a/src/operations/clean.rs +++ b/src/operations/clean.rs @@ -49,18 +49,19 @@ pub async fn clean(options: Options) { tracing::debug!("Removing orphans: {:?}", orphaned_packages_vec); // Remove orphaned packages - PacmanUninstallBuilder::default() + let result = PacmanUninstallBuilder::default() .no_save(true) .recursive(true) .no_confirm(noconfirm) .packages(orphaned_packages_vec) .uninstall() - .await - .unwrap_or_else(|_| { - crash!(AppExitCode::PacmanError, "Failed to remove orphans",); - }); + .await; - tracing::info!("Successfully removed orphans"); + if let Err(_) = result { + crash!(AppExitCode::PacmanError, "Failed to remove orphans"); + } else { + tracing::info!("Successfully removed orphans"); + } } // Prompt the user whether to clear the Amethyst cache @@ -89,20 +90,21 @@ pub async fn clean(options: Options) { // Clear pacman's cache // keeps 0 versions of the package in the cache by default // keeps installed packages in the cache by default - PaccacheBuilder::default() + let result = PaccacheBuilder::default() .keep(conf.base.paccache_keep) .keep_ins(conf.base.paccache_keep_ins) .quiet(quiet) .remove() - .await - .unwrap_or_else(|e| { - crash!( - AppExitCode::PacmanError, - "Failed to clear package cache, {}", - e - ) - }); + .await; - tracing::info!("Successfully cleared package cache"); + if let Err(e) = result { + crash!( + AppExitCode::PacmanError, + "Failed to clear package cache, {}", + e + ) + } else { + tracing::info!("Successfully cleared package cache"); + } } } diff --git a/src/operations/upgrade.rs b/src/operations/upgrade.rs index 9a6110a..433c5ba 100644 --- a/src/operations/upgrade.rs +++ b/src/operations/upgrade.rs @@ -28,20 +28,22 @@ async fn upgrade_repo(options: Options) { tracing::debug!("Upgrading repo packages"); - PacmanUpgradeBuilder::default() + let result = PacmanUpgradeBuilder::default() .no_confirm(noconfirm) .upgrade() - .await - .unwrap_or_else(|_| { - let continue_upgrading = prompt!(default no, - "Failed to upgrade repo packages, continue to upgrading AUR packages?", - ); - if !continue_upgrading { - tracing::info!("Exiting"); - std::process::exit(AppExitCode::PacmanError as i32); - } - }); - tracing::info!("Successfully upgraded repo packages"); + .await; + + if let Err(_) = result { + let continue_upgrading = prompt!(default no, + "Failed to upgrade repo packages, continue to upgrading AUR packages?", + ); + if !continue_upgrading { + tracing::info!("Exiting"); + std::process::exit(AppExitCode::PacmanError as i32); + } + } else { + tracing::info!("Successfully upgraded repo packages"); + } } #[tracing::instrument(level = "trace")]