From 25d13f779ce1c30e72bf5307607fec3d3b225384 Mon Sep 17 00:00:00 2001 From: Tarek Date: Tue, 6 Feb 2024 16:38:23 +0200 Subject: [PATCH] fix(coffee): only upgrade plugins if needed Revise the plugin upgrade logic to only perform upgrades to plugins if the repository was updated. This prevents unnecessary plugin upgrades. Signed-off-by: Tarek --- coffee_core/src/coffee.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/coffee_core/src/coffee.rs b/coffee_core/src/coffee.rs index a548cf9..67cac36 100644 --- a/coffee_core/src/coffee.rs +++ b/coffee_core/src/coffee.rs @@ -352,10 +352,18 @@ impl PluginManager for CoffeeManager { .ok_or_else(|| error!("Repository with name: `{}` not found", repo))?; let status = repository.upgrade(&self.config.plugins, verbose).await?; - for plugins in status.plugins_effected.iter() { - self.remove(plugins).await?; - self.install(plugins, verbose, false).await?; + + // if status is not up to date, we need to update the plugins as well + match status.status { + UpgradeStatus::UpToDate(_, _) => {} + _ => { + for plugins in status.plugins_effected.iter() { + self.remove(plugins).await?; + self.install(plugins, verbose, false).await?; + } + } } + self.flush().await?; Ok(status) }