Don't use PosixPermission on Windows, when creating temp plugin folders

This commit is contained in:
Boaz Leskes 2016-03-19 11:35:05 +01:00
parent f71f0d6010
commit ee95c0a384
1 changed files with 53 additions and 47 deletions

View File

@ -21,6 +21,7 @@ package org.elasticsearch.plugins;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.IOUtils;
import org.elasticsearch.Build;
import org.elasticsearch.Version;
@ -241,6 +242,10 @@ class InstallPluginCommand extends Command {
private Path unzip(Path zip, Path pluginsDir) throws IOException, UserError {
// unzip plugin to a staging temp dir
final Path target;
if (Constants.WINDOWS) {
target = Files.createTempDirectory(pluginsDir, ".installing-");
} else {
Set<PosixFilePermission> perms = new HashSet<>();
perms.add(PosixFilePermission.OWNER_EXECUTE);
perms.add(PosixFilePermission.OWNER_READ);
@ -249,7 +254,8 @@ class InstallPluginCommand extends Command {
perms.add(PosixFilePermission.GROUP_EXECUTE);
perms.add(PosixFilePermission.OTHERS_READ);
perms.add(PosixFilePermission.OTHERS_EXECUTE);
Path target = Files.createTempDirectory(pluginsDir, ".installing-", PosixFilePermissions.asFileAttribute(perms));
target = Files.createTempDirectory(pluginsDir, ".installing-", PosixFilePermissions.asFileAttribute(perms));
}
Files.createDirectories(target);
boolean hasEsDir = false;