mirror of
https://github.com/airsonic/airsonic.git
synced 2025-10-03 17:59:25 +02:00
Use PropertiesLoaderUtils when reading HSQLDB .properties file
This commit is contained in:
parent
ff7ded3f80
commit
cbab1434c2
1 changed files with 5 additions and 6 deletions
|
@ -4,11 +4,11 @@ import org.airsonic.player.service.SettingsService;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.core.io.FileSystemResource;
|
||||||
|
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
@ -24,15 +24,14 @@ public class LegacyHsqlUtil {
|
||||||
* Return the current version of the HSQLDB database, as reported by the database properties file.
|
* Return the current version of the HSQLDB database, as reported by the database properties file.
|
||||||
*/
|
*/
|
||||||
public static String getHsqldbDatabaseVersion() {
|
public static String getHsqldbDatabaseVersion() {
|
||||||
Properties prop = new Properties();
|
|
||||||
File configFile = new File(SettingsService.getDefaultJDBCPath() + ".properties");
|
File configFile = new File(SettingsService.getDefaultJDBCPath() + ".properties");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
LOG.debug("HSQLDB database doesn't exist, cannot determine version");
|
LOG.debug("HSQLDB database doesn't exist, cannot determine version");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try (InputStream stream = new FileInputStream(configFile)) {
|
try {
|
||||||
prop.load(stream);
|
Properties properties = PropertiesLoaderUtils.loadProperties(new FileSystemResource(configFile));
|
||||||
return prop.getProperty("version");
|
return properties.getProperty("version");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Failed to determine HSQLDB database version", e);
|
LOG.error("Failed to determine HSQLDB database version", e);
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue