mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-22 15:32:16 +01:00
cancel installation on pending plugins
This commit is contained in:
@@ -5,7 +5,7 @@ import com.google.common.base.Preconditions;
|
||||
public class AvailablePlugin implements Plugin {
|
||||
|
||||
private final AvailablePluginDescriptor pluginDescriptor;
|
||||
private final boolean pending;
|
||||
private boolean pending;
|
||||
|
||||
public AvailablePlugin(AvailablePluginDescriptor pluginDescriptor) {
|
||||
this(pluginDescriptor, false);
|
||||
@@ -25,6 +25,10 @@ public class AvailablePlugin implements Plugin {
|
||||
return pending;
|
||||
}
|
||||
|
||||
public void cancelInstallation() {
|
||||
this.pending = false;
|
||||
}
|
||||
|
||||
public AvailablePlugin install() {
|
||||
Preconditions.checkState(!pending, "installation is already pending");
|
||||
return new AvailablePlugin(pluginDescriptor, true);
|
||||
|
||||
@@ -109,5 +109,5 @@ public interface PluginManager {
|
||||
/**
|
||||
* Update all installed plugins.
|
||||
*/
|
||||
void updateAll(boolean restartAfterInstallation);
|
||||
void updateAll();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class InstalledPluginResource {
|
||||
})
|
||||
@TypeHint(CollectionDto.class)
|
||||
public Response updateAll(@QueryParam("restart") boolean restartAfterInstallation) {
|
||||
pluginManager.updateAll(restartAfterInstallation);
|
||||
pluginManager.updateAll();
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
|
||||
@@ -288,17 +288,19 @@ public class DefaultPluginManager implements PluginManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAll(boolean restartAfterInstallation) {
|
||||
public void updateAll() {
|
||||
PluginPermissions.manage().check();
|
||||
boolean pluginUpdated = false;
|
||||
|
||||
for (InstalledPlugin installedPlugin : getInstalled()) {
|
||||
String pluginName = installedPlugin.getDescriptor().getInformation().getName();
|
||||
if (isUpdatable(pluginName)) {
|
||||
install(pluginName, false);
|
||||
pluginUpdated = true;
|
||||
}
|
||||
if (restartAfterInstallation) {
|
||||
restart("update all plugin");
|
||||
}
|
||||
}
|
||||
if (pluginUpdated) {
|
||||
restart("update all plugins");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class PendingPluginInstallation {
|
||||
LOG.info("cancel installation of plugin {}", name);
|
||||
try {
|
||||
Files.delete(file);
|
||||
plugin.cancelInstallation();
|
||||
} catch (IOException ex) {
|
||||
throw new PluginFailedToCancelInstallationException("failed to cancel installation of plugin " + name, ex);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ class DefaultPluginManagerTest {
|
||||
|
||||
when(center.getAvailable()).thenReturn(ImmutableSet.of(newMailPlugin, newReviewPlugin));
|
||||
|
||||
manager.updateAll(false);
|
||||
manager.updateAll();
|
||||
|
||||
verify(installer).install(newMailPlugin);
|
||||
verify(installer).install(newReviewPlugin);
|
||||
@@ -503,7 +503,7 @@ class DefaultPluginManagerTest {
|
||||
|
||||
when(center.getAvailable()).thenReturn(ImmutableSet.of(oldScriptPlugin));
|
||||
|
||||
manager.updateAll(false);
|
||||
manager.updateAll();
|
||||
|
||||
verify(installer, never()).install(oldScriptPlugin);
|
||||
}
|
||||
@@ -569,7 +569,7 @@ class DefaultPluginManagerTest {
|
||||
|
||||
@Test
|
||||
void shouldThrowAuthorizationExceptionsForUpdateAll() {
|
||||
assertThrows(AuthorizationException.class, () -> manager.updateAll(false));
|
||||
assertThrows(AuthorizationException.class, () -> manager.updateAll());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user