Cleanup (simplification)

This commit is contained in:
Roman Shevchenko
2017-08-10 16:40:10 +02:00
parent e9972bacf5
commit 7f6c078a6a
2 changed files with 5 additions and 11 deletions
@@ -135,12 +135,11 @@ object UpdateInstaller {
val args = arrayListOf<String>()
if (SystemInfo.isWindows) {
// launcher depends on elevator
val launcher = PathManager.findBinFile("launcher.exe")
val elevator = PathManager.findBinFile("elevator.exe")
if (launcher !=null && elevator != null && launcher.canExecute()) {
args += Restarter.createTempExecutable(launcher, elevator).path
val elevator = PathManager.findBinFile("elevator.exe") // "launcher" depends on "elevator"
if (launcher != null && elevator != null && launcher.canExecute() && elevator.canExecute()) {
Restarter.createTempExecutable(elevator)
args += Restarter.createTempExecutable(launcher).path
}
}
@@ -210,7 +210,7 @@ public class Restarter {
}
@NotNull
public static File createTempExecutable(@NotNull File executable, @NotNull final File ...filesToCopyToSameFolder) throws IOException {
public static File createTempExecutable(@NotNull File executable) throws IOException {
File tempDir = new File(PathManager.getSystemPath(), "restart");
if (!FileUtilRt.createDirectory(tempDir)) {
throw new IOException("Cannot create directory: " + tempDir);
@@ -224,11 +224,6 @@ public class Restarter {
copy = FileUtilRt.createTempFile(tempDir, prefix, suffix, true, false);
}
FileUtilRt.copy(executable, copy);
final File directory = copy.getParentFile();
for (final File fileToCopy : filesToCopyToSameFolder) {
FileUtilRt.copy(fileToCopy, new File(directory, fileToCopy.getName()));
}
if (executable.canExecute() && !copy.setExecutable(true)) {
throw new IOException("Cannot make file executable: " + copy);