mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
Mirror uninstall state in plugin object
This commit is contained in:
@@ -127,6 +127,14 @@ public final class InstalledPlugin implements Plugin
|
|||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMarkedForUninstall() {
|
||||||
|
return markedForUninstall;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkedForUninstall(boolean markedForUninstall) {
|
||||||
|
this.markedForUninstall = markedForUninstall;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** plugin class loader */
|
/** plugin class loader */
|
||||||
@@ -142,4 +150,6 @@ public final class InstalledPlugin implements Plugin
|
|||||||
private final WebResourceLoader webResourceLoader;
|
private final WebResourceLoader webResourceLoader;
|
||||||
|
|
||||||
private final boolean core;
|
private final boolean core;
|
||||||
|
|
||||||
|
private boolean markedForUninstall;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ public class DefaultPluginManager implements PluginManager {
|
|||||||
doThrow().violation("plugin is a core plugin and cannot be uninstalled").when(installed.isCore());
|
doThrow().violation("plugin is a core plugin and cannot be uninstalled").when(installed.isCore());
|
||||||
|
|
||||||
dependencyTracker.removeInstalled(installed.getDescriptor());
|
dependencyTracker.removeInstalled(installed.getDescriptor());
|
||||||
|
installed.setMarkedForUninstall(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Files.createFile(installed.getDirectory().resolve(InstalledPlugin.UNINSTALL_MARKER_FILENAME));
|
Files.createFile(installed.getDirectory().resolve(InstalledPlugin.UNINSTALL_MARKER_FILENAME));
|
||||||
|
|||||||
@@ -345,6 +345,18 @@ class DefaultPluginManagerTest {
|
|||||||
assertThat(temp.resolve("uninstall")).exists();
|
assertThat(temp.resolve("uninstall")).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldMarkPluginForUninstall(@TempDirectory.TempDir Path temp) {
|
||||||
|
InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin");
|
||||||
|
when(mailPlugin.getDirectory()).thenReturn(temp);
|
||||||
|
|
||||||
|
when(loader.getInstalledPlugins()).thenReturn(singletonList(mailPlugin));
|
||||||
|
|
||||||
|
manager.uninstall("scm-mail-plugin", false);
|
||||||
|
|
||||||
|
verify(mailPlugin).setMarkedForUninstall(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldThrowExceptionWhenUninstallingCorePlugin(@TempDirectory.TempDir Path temp) {
|
void shouldThrowExceptionWhenUninstallingCorePlugin(@TempDirectory.TempDir Path temp) {
|
||||||
InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin");
|
InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin");
|
||||||
|
|||||||
Reference in New Issue
Block a user