From 544714171819467ed80845cd97eb2985075fde5b Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Thu, 13 Jul 2017 18:33:36 -0600 Subject: [PATCH] Setup backwards compatiblity with old libresonic.home Signed-off-by: Andrew DeMaria --- .../airsonic/player/service/SettingsService.java | 16 ++++++++++++++-- .../resources/applicationContext-db-legacy.xml | 3 ++- .../test/resources/applicationContext-testdb.xml | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/service/SettingsService.java b/airsonic-main/src/main/java/org/airsonic/player/service/SettingsService.java index 82c5a16c..728ecb89 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/service/SettingsService.java +++ b/airsonic-main/src/main/java/org/airsonic/player/service/SettingsService.java @@ -240,8 +240,11 @@ public class SettingsService { File home; String overrideHome = System.getProperty("airsonic.home"); + String oldHome = System.getProperty("libresonic.home"); if (overrideHome != null) { home = new File(overrideHome); + } else if(oldHome != null) { + home = new File(oldHome); } else { boolean isWindows = System.getProperty("os.name", "Windows").toLowerCase().startsWith("windows"); home = isWindows ? AIRSONIC_HOME_WINDOWS : AIRSONIC_HOME_OTHER; @@ -251,9 +254,18 @@ public class SettingsService { return home; } + public static String getFileSystemAppName() { + String home = getAirsonicHome().getPath(); + return home.contains("libresonic") ? "libresonic" : "airsonic"; + } + + public static String getDefaultJDBCUrl() { + return "jdbc:hsqldb:file:" + getAirsonicHome().getPath() + "/db/" + getFileSystemAppName(); + } + public static File getLogFile() { File airsonicHome = SettingsService.getAirsonicHome(); - return new File(airsonicHome, "airsonic.log"); + return new File(airsonicHome, getFileSystemAppName() + ".log"); } @@ -298,7 +310,7 @@ public class SettingsService { public static File getPropertyFile() { File propertyFile = getAirsonicHome(); - return new File(propertyFile, "airsonic.properties"); + return new File(propertyFile, getFileSystemAppName() + ".properties"); } private int getInt(String key, int defaultValue) { diff --git a/airsonic-main/src/main/resources/applicationContext-db-legacy.xml b/airsonic-main/src/main/resources/applicationContext-db-legacy.xml index 76b83afd..f866f385 100644 --- a/airsonic-main/src/main/resources/applicationContext-db-legacy.xml +++ b/airsonic-main/src/main/resources/applicationContext-db-legacy.xml @@ -8,7 +8,8 @@ class="org.springframework.jdbc.datasource.DriverManagerDataSource"> - + diff --git a/airsonic-main/src/test/resources/applicationContext-testdb.xml b/airsonic-main/src/test/resources/applicationContext-testdb.xml index 6372c3ec..dda560c6 100644 --- a/airsonic-main/src/test/resources/applicationContext-testdb.xml +++ b/airsonic-main/src/test/resources/applicationContext-testdb.xml @@ -7,7 +7,8 @@ class="org.springframework.jdbc.datasource.DriverManagerDataSource"> - +