mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-31 01:30:00 +02:00
utils, java.nio for config file load
This commit is contained in:
@@ -72,9 +72,9 @@ public class Utils {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String configPath = getConfigFilePath();
|
String configPath = getConfigFilePath();
|
||||||
File file = new File(configPath);
|
Path file = Paths.get(configPath);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!Files.exists(file)) {
|
||||||
// Use default bundled with .jar
|
// Use default bundled with .jar
|
||||||
configPath = CONFIG_FILE;
|
configPath = CONFIG_FILE;
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public class Utils {
|
|||||||
config = new PropertiesConfiguration(configPath);
|
config = new PropertiesConfiguration(configPath);
|
||||||
LOGGER.info("Loaded " + config.getPath());
|
LOGGER.info("Loaded " + config.getPath());
|
||||||
|
|
||||||
if (file.exists()) {
|
if (Files.exists(file)) {
|
||||||
// Config was loaded from file
|
// Config was loaded from file
|
||||||
if (!config.containsKey("twitter.auth") || !config.containsKey("twitter.max_requests")
|
if (!config.containsKey("twitter.auth") || !config.containsKey("twitter.max_requests")
|
||||||
|| !config.containsKey("tumblr.auth") || !config.containsKey("error.skip404")
|
|| !config.containsKey("tumblr.auth") || !config.containsKey("error.skip404")
|
||||||
@@ -92,7 +92,7 @@ public class Utils {
|
|||||||
// Need to reload the default config
|
// Need to reload the default config
|
||||||
// See https://github.com/4pr0n/ripme/issues/158
|
// See https://github.com/4pr0n/ripme/issues/158
|
||||||
LOGGER.warn("Config does not contain key fields, deleting old config");
|
LOGGER.warn("Config does not contain key fields, deleting old config");
|
||||||
file.delete();
|
Files.delete(file);
|
||||||
config = new PropertiesConfiguration(CONFIG_FILE);
|
config = new PropertiesConfiguration(CONFIG_FILE);
|
||||||
LOGGER.info("Loaded " + config.getPath());
|
LOGGER.info("Loaded " + config.getPath());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user