diff --git a/build.gradle b/build.gradle index 832527e..e2654ce 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,8 @@ plugins { // Set version of programm // -version = "1.0.4" -def version = "1.0.4" +version = "1.0.5" +def version = "1.0.5" group = "de.rpjosh" diff --git a/src/main/java/de/rpjosh/installer/InstallConfig.java b/src/main/java/de/rpjosh/installer/InstallConfig.java index bea48a2..875e4db 100644 --- a/src/main/java/de/rpjosh/installer/InstallConfig.java +++ b/src/main/java/de/rpjosh/installer/InstallConfig.java @@ -83,6 +83,8 @@ public class InstallConfig { private int maxHeapSize = 0; private int initialHeapSize = 0; + protected boolean killRunningInstances = true; + // ----- // // systemd settings // @@ -175,6 +177,16 @@ public class InstallConfig { protected boolean getIsUser() { return isUser; } protected boolean getIsPortable() { return isPortable; } + /** + * By default all running instances will be killed before the installation starts. + * This behavior can be toggled through this method + * + * @param kill If the running instances should be killed + */ + public void setKillRunningInstance(boolean kill) { + this.killRunningInstances = kill; + } + /** * The given fonts will be installed (the fonts has to be in the format .ttf) @@ -500,7 +512,9 @@ public class InstallConfig { } this.configDir = rtc; - this.initConfigDir(); + if (!this.initConfigDir()) { + this.configDir = ""; + } return rtc; } @@ -517,18 +531,26 @@ public class InstallConfig { initConfigDir(); } - private void initConfigDir() { + private boolean initConfigDir() { - if (!isInstallationStarted) return; // before the start of the installation no folders will be created + if (!isInstallationStarted) return false; // before the start of the installation no folders will be created String rtc = this.configDir; + // Create the root application directory + File configDirectory = new File(rtc); + if (!configDirectory.exists()) new File(rtc).mkdirs(); + try { for (String direcotory: directorysInConfig) { File currentDirectory = new File(rtc + direcotory); if (!currentDirectory.exists()) new File(rtc + direcotory).mkdirs(); } + + return true; } catch (Exception ex) { logger.log("e", ex, "getConfigDir"); } + + return false; } @@ -556,7 +578,9 @@ public class InstallConfig { } this.applicationDir = rtc; - initApplicationDir(); + if (!initApplicationDir()) { + this.applicationDir = ""; + }; return rtc; } @@ -573,9 +597,9 @@ public class InstallConfig { initApplicationDir(); // isn't done right here -> directories will be created before the installation and not now } - protected void initApplicationDir() { + protected boolean initApplicationDir() { - if (!isInstallationStarted) return; // before the installation no directory is been created + if (!isInstallationStarted) return false; // before the installation no directory is been created // if an path entry should be added (only for windows) the path variable points to an own folder if (InstallConfig.getOsType() == OSType.WINDOWS && this.createPathVariable && !directorysInAppData.contains("path/")) { @@ -587,12 +611,20 @@ public class InstallConfig { String rtc = this.applicationDir; + // Create the root application directory + File applicationDirectory = new File(rtc); + if (!applicationDirectory.exists()) new File(rtc).mkdirs(); + try { for (String directory: directorysInAppData) { File currentDirectory = new File(rtc + directory); if (!currentDirectory.exists()) new File(rtc + directory).mkdirs(); } + + return true; } catch (Exception ex) { logger.log("e", ex, "initApplicationDir"); } + + return false; } /** diff --git a/src/main/java/de/rpjosh/installer/Installer.java b/src/main/java/de/rpjosh/installer/Installer.java index fcb070e..d969c75 100644 --- a/src/main/java/de/rpjosh/installer/Installer.java +++ b/src/main/java/de/rpjosh/installer/Installer.java @@ -94,8 +94,8 @@ public class Installer { System.out.println(Tr.get("installation_start", conf.getApplicationNameShort(), conf.getVersion()) + "\n"); - // all running instances will be killed - this.killRunningInstances(); + // All running instances will be killed + if (conf.killRunningInstances) this.killRunningInstances(); System.out.print(Tr.get("installation_architekture") + ": "); String aarch = this.getVersionOfProgramm();