From 9bef681a18ec1d4e61737abe074d7ec34ae9e5a2 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Wed, 19 Oct 2022 23:22:08 +0200 Subject: [PATCH] Fixed #586 - make search for available updates working for tomcat --- .../BudgetMasterUpdateConfiguration.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/update/BudgetMasterUpdateConfiguration.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/update/BudgetMasterUpdateConfiguration.java index 3c15bbc6e..0777f6bcb 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/update/BudgetMasterUpdateConfiguration.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/update/BudgetMasterUpdateConfiguration.java @@ -21,6 +21,9 @@ import java.nio.file.Paths; @Component public class BudgetMasterUpdateConfiguration { + @SuppressWarnings("java:S1075") + private static final String TOMCAT_PATH = "/usr/local/tomcat"; + private UpdateService.Strategy updateStrategy; private String executablePath; private RemoteFile.FileType fileType; @@ -36,7 +39,6 @@ public class BudgetMasterUpdateConfiguration @PostConstruct private void postInit() { - final File source = new ApplicationHome().getSource(); executablePath = null; updateStrategy = UpdateService.Strategy.JAR; fileType = RemoteFile.FileType.JAR; @@ -44,7 +46,18 @@ public class BudgetMasterUpdateConfiguration SystemUtils.setIsJarHook(new IsJarFileHook()); SystemUtils.setIsExeHook(new IsExeFileHook()); - if(source != null) + final ApplicationHome applicationHome = new ApplicationHome(); + final File source = applicationHome.getSource(); + if(source == null) + { + final String appHomeDirectory = applicationHome.getDir().getAbsolutePath(); + if(appHomeDirectory.equals(TOMCAT_PATH)) + { + isRunningFromSource = false; + executablePath = appHomeDirectory; + } + } + else { isRunningFromSource = false; executablePath = source.getAbsolutePath(); @@ -64,7 +77,7 @@ public class BudgetMasterUpdateConfiguration VersionizerItem versionizerItem = new VersionizerItem(repository, executablePath); UpdateService versionizerUpdateService = UpdateService.startVersionizer(versionizerItem, updateStrategy, UpdateService.InteractionType.HEADLESS, UpdateService.RepositoryType.RELEASE); - if(executablePath != null) + if(!isRunningFromSource) { versionizerUpdateService.addArtifact(artifact, Paths.get(executablePath)); } -- GitLab