diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/PluginServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/PluginServiceCEImpl.java index 8079f0c570..1afd2fed3c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/PluginServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/PluginServiceCEImpl.java @@ -200,8 +200,13 @@ public class PluginServiceCEImpl extends BaseService { - organization.getPlugins().addAll(newOrganizationPlugins); - return organizationService.save(organization); + // Only perform a DB op if plugins associated to this org have changed + if (organization.getPlugins().containsAll(newOrganizationPlugins)) { + return Mono.just(organization); + } else { + organization.getPlugins().addAll(newOrganizationPlugins); + return organizationService.save(organization); + } }); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PluginScheduledTaskCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PluginScheduledTaskCEImpl.java index 0ca17980ef..e829923329 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PluginScheduledTaskCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PluginScheduledTaskCEImpl.java @@ -69,8 +69,17 @@ public class PluginScheduledTaskCEImpl implements PluginScheduledTaskCE { } }); - final Mono> updatedPluginsFlux = pluginService.saveAll(updatablePlugins) + // Save new data for this plugin, + // then make sure to install to organizations in case the default installation flag changed + final Mono> updatedPluginsOrganizationFlux = pluginService + .saveAll(updatablePlugins) + .filter(Plugin::getDefaultInstall) + .collectList() + .flatMapMany(pluginService::installDefaultPlugins) .collectList(); + + // Create plugin, + // then install to all organizations if default installation is turned on final Mono> organizationFlux = Flux.fromIterable(insertablePlugins) .flatMap(pluginService::create) @@ -79,7 +88,7 @@ public class PluginScheduledTaskCEImpl implements PluginScheduledTaskCE { .flatMapMany(pluginService::installDefaultPlugins) .collectList(); - return updatedPluginsFlux + return updatedPluginsOrganizationFlux .zipWith(organizationFlux) .then(); })