mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-07 16:41:45 +02:00
Fetch exception when uninstall file could not be written
This commit is contained in:
@@ -193,9 +193,14 @@ public class DefaultPluginManager implements PluginManager {
|
||||
doThrow().violation("plugin is a core plugin and cannot be uninstalled").when(installed.isCore());
|
||||
|
||||
dependencyTracker.removeInstalled(installed.getDescriptor());
|
||||
installed.setMarkedForUninstall(true);
|
||||
|
||||
createMarkerFile(installed, InstalledPlugin.UNINSTALL_MARKER_FILENAME);
|
||||
try {
|
||||
createMarkerFile(installed, InstalledPlugin.UNINSTALL_MARKER_FILENAME);
|
||||
installed.setMarkedForUninstall(true);
|
||||
} catch (RuntimeException e) {
|
||||
dependencyTracker.addInstalled(installed.getDescriptor());
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (restartAfterInstallation) {
|
||||
restart("plugin installation");
|
||||
|
||||
@@ -33,6 +33,10 @@ class PluginDependencyTracker {
|
||||
}
|
||||
|
||||
private void removeDependency(String from, String to) {
|
||||
plugins.get(to).remove(from);
|
||||
Collection<String> dependencies = plugins.get(to);
|
||||
if (dependencies == null) {
|
||||
throw new NullPointerException("inverse dependencies not found for " + to);
|
||||
}
|
||||
dependencies.remove(from);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,6 +358,24 @@ class DefaultPluginManagerTest {
|
||||
verify(mailPlugin).setMarkedForUninstall(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotChangeStateWhenUninstallFileCouldNotBeCreated() {
|
||||
InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin");
|
||||
InstalledPlugin reviewPlugin = createInstalled("scm-review-plugin");
|
||||
when(reviewPlugin.getDescriptor().getDependencies()).thenReturn(singleton("scm-mail-plugin"));
|
||||
|
||||
when(reviewPlugin.getDirectory()).thenThrow(new PluginException("when the file could not be written an exception like this is thrown"));
|
||||
|
||||
when(loader.getInstalledPlugins()).thenReturn(asList(mailPlugin, reviewPlugin));
|
||||
|
||||
manager.computeInstallationDependencies();
|
||||
|
||||
assertThrows(PluginException.class, () -> manager.uninstall("scm-review-plugin", false));
|
||||
|
||||
verify(mailPlugin, never()).setMarkedForUninstall(true);
|
||||
assertThrows(ScmConstraintViolationException.class, () -> manager.uninstall("scm-mail-plugin", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenUninstallingCorePlugin(@TempDirectory.TempDir Path temp) {
|
||||
InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin");
|
||||
|
||||
Reference in New Issue
Block a user