Skip to content

Commit

Permalink
plugin -remove deletes bin directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dadoonet committed Oct 8, 2013
1 parent e9f3677 commit b254a31
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/elasticsearch/plugins/PluginManager.java
Expand Up @@ -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;
Expand Down Expand Up @@ -221,6 +223,10 @@ public void removePlugin(String name) throws IOException {
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());
Expand Down Expand Up @@ -331,6 +337,7 @@ public static void main(String[] args) {
// 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;
Expand Down Expand Up @@ -371,6 +378,9 @@ public static void main(String[] args) {
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());
Expand Down

0 comments on commit b254a31

Please sign in to comment.