added backup root checking to config checking
This commit is contained in:
parent
9877fe5c2c
commit
1ffcfa6c0e
@ -21,6 +21,7 @@ package net.szum123321.textile_backup;
|
||||
import blue.endless.jankson.Comment;
|
||||
import io.github.cottonmc.cotton.config.annotations.ConfigFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
@ -108,6 +109,16 @@ public class ConfigHandler {
|
||||
return Optional.of("dateTimeFormat is wrong!\n" + e.getMessage() + "\n See: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html");
|
||||
}
|
||||
|
||||
File path = new File(Statics.CONFIG.path).getAbsoluteFile();
|
||||
|
||||
if (!path.exists()) {
|
||||
try {
|
||||
path.mkdirs();
|
||||
} catch (Exception e) {
|
||||
return Optional.of("Something went wrong while creating backup folder!\n" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
@ -134,18 +134,7 @@ public class Utilities {
|
||||
path = path.toPath().resolve(worldName).toFile();
|
||||
|
||||
if (!path.exists()) {
|
||||
try {
|
||||
path.mkdirs();
|
||||
} catch (Exception e) {
|
||||
Statics.LOGGER.error("An exception occurred!", e);
|
||||
|
||||
return FabricLoader
|
||||
.getInstance()
|
||||
.getGameDirectory()
|
||||
.toPath()
|
||||
.resolve(Statics.CONFIG.path)
|
||||
.toFile();
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
|
Loading…
Reference in New Issue
Block a user