From dd218777d64571fd0d62dc355d9969bbc7290949 Mon Sep 17 00:00:00 2001 From: Tarek Date: Tue, 6 Feb 2024 20:16:38 +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 a01e21a..98e32c9 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::Updated(_, _) => { + for plugins in status.plugins_effected.iter() { + self.remove(plugins).await?; + self.install(plugins, verbose, false).await?; + } + } + _ => {} } + self.flush().await?; Ok(status) }