for (String uninstallKey : uninstallKeys) {
PluginInfo info = getPluginInfo(uninstallKey);
+
try {
+ if (!getPluginFile(info).exists()) {
+ LOG.info("Plugin already uninstalled: {} [{}]", info.getName(), info.getKey());
+ continue;
+ }
+
LOG.info("Uninstalling plugin {} [{}]", info.getName(), info.getKey());
- File masterFile = pluginFile(info);
+ File masterFile = getPluginFile(info);
moveFileToDirectory(masterFile, uninstallDir, true);
} catch (IOException e) {
throw new IllegalStateException(format("Fail to uninstall plugin %s [%s]", info.getName(), info.getKey()), e);
for (PluginInfo otherPlugin : getPluginInfos()) {
if (!otherPlugin.getKey().equals(pluginKey)) {
for (PluginInfo.RequiredPlugin requirement : otherPlugin.getRequiredPlugins()) {
- if (requirement.getKey().equals(pluginKey) && pluginFile(otherPlugin).exists()) {
+ if (requirement.getKey().equals(pluginKey)) {
appendTo.add(otherPlugin.getKey());
appendDependentPluginKeys(otherPlugin.getKey(), appendTo);
}
}
}
- private File pluginFile(PluginInfo info) {
+ private File getPluginFile(PluginInfo info) {
// we don't reuse info.getFile() just to be sure that file is located in from extensions/plugins
return new File(fs.getInstalledPluginsDir(), info.getNonNullJarFile().getName());
}
assertThat(uninstallDir.list()).containsOnly(base.getName(), extension.getName());
}
+ @Test
+ public void dont_uninstall_non_existing_files() throws IOException {
+ File base = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
+ File extension = copyTestPluginTo("test-require-plugin", fs.getInstalledPluginsDir());
+ File uninstallDir = temp.newFolder("uninstallDir");
+
+ underTest.start();
+ assertThat(underTest.getPluginInfos()).hasSize(2);
+ underTest.uninstall("testbase", uninstallDir);
+ assertThat(underTest.getPluginInfos()).hasSize(2);
+
+ underTest.uninstall("testbase", uninstallDir);
+ assertThat(base).doesNotExist();
+ assertThat(extension).doesNotExist();
+ assertThat(uninstallDir.list()).containsOnly(base.getName(), extension.getName());
+ }
+
@Test
public void install_plugin_and_its_extension_plugins_at_startup() throws Exception {
copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());