plugin -remove deletes bin directory
I tried to install a plugin directly from disk, but used the wrong arguments. Totally my fault for not RTFM properly. However, by following the instructions printed out by `bin/plugin`, I ended up deleting my $ES/bin directory. ``` $ pwd /tmp/elasticsearch-0.90.5 $ ls LICENSE.txt NOTICE.txt README.textile bin config lib $ bin/plugin --install file:///tmp/foo.zip -> Installing file:///tmp/foo.zip... Failed to install file:///tmp/foo.zip, reason: plugin directory /tmp/elasticsearch-0.90.5/plugins already exists. To update the plugin, uninstall it first using -remove file:///tmp/foo.zip command $ bin/plugin -remove file:///tmp/foo.zip -> Removing file:///tmp/foo.zip Removed file:///tmp/foo.zip $ ls LICENSE.txt NOTICE.txt README.textile config lib ``` I reproduced the problem in 0.90.5 and the latest master. Closes #3847.
This commit is contained in:
parent
6b02611971
commit
4ee7f3521f
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.plugins;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.http.client.HttpDownloadHelper;
|
||||
|
@ -221,6 +223,10 @@ public class PluginManager {
|
|||
PluginHandle pluginHandle = PluginHandle.parse(name);
|
||||
boolean removed = false;
|
||||
|
||||
if (Strings.isNullOrEmpty(pluginHandle.name)) {
|
||||
throw new ElasticSearchIllegalArgumentException("plugin name is incorrect");
|
||||
}
|
||||
|
||||
File pluginToDelete = pluginHandle.extractedDir(environment);
|
||||
if (pluginToDelete.exists()) {
|
||||
debug("Removing: " + pluginToDelete.getPath());
|
||||
|
@ -331,6 +337,7 @@ public class PluginManager {
|
|||
// Deprecated commands
|
||||
|| command.equals("remove") || command.equals("-remove")) {
|
||||
pluginName = args[++c];
|
||||
|
||||
action = ACTION.REMOVE;
|
||||
} else if (command.equals("-l") || command.equals("--list")) {
|
||||
action = ACTION.LIST;
|
||||
|
@ -371,6 +378,9 @@ public class PluginManager {
|
|||
pluginManager.log("-> Removing " + pluginName + " ");
|
||||
pluginManager.removePlugin(pluginName);
|
||||
exitCode = EXIT_CODE_OK;
|
||||
} catch (ElasticSearchIllegalArgumentException e) {
|
||||
exitCode = EXIT_CODE_CMD_USAGE;
|
||||
pluginManager.log("Failed to remove " + pluginName + ", reason: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
exitCode = EXIT_CODE_IO_ERROR;
|
||||
pluginManager.log("Failed to remove " + pluginName + ", reason: " + e.getMessage());
|
||||
|
|
Loading…
Reference in New Issue