Fix init error in SeparatedConfigurateDao (#924 & #925)

This commit is contained in:
Luck 2018-04-21 17:03:59 +01:00
parent 328353d053
commit 1b917f0901
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 13 additions and 3 deletions

View File

@ -34,6 +34,7 @@ import me.lucko.luckperms.common.node.NodeHeldPermission;
import me.lucko.luckperms.common.node.NodeModel;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.storage.dao.file.loader.ConfigurateLoader;
import me.lucko.luckperms.common.utils.MoreFiles;
import me.lucko.luckperms.common.utils.Uuids;
import ninja.leaping.configurate.ConfigurationNode;
@ -147,9 +148,9 @@ public class SeparatedConfigurateDao extends AbstractConfigurateDao {
public void init() throws IOException {
super.init();
this.usersDirectory = Files.createDirectory(super.dataDirectory.resolve("users"));
this.groupsDirectory = Files.createDirectory(super.dataDirectory.resolve("groups"));
this.tracksDirectory = Files.createDirectory(super.dataDirectory.resolve("tracks"));
this.usersDirectory = MoreFiles.createDirectoryIfNotExists(super.dataDirectory.resolve("users"));
this.groupsDirectory = MoreFiles.createDirectoryIfNotExists(super.dataDirectory.resolve("groups"));
this.tracksDirectory = MoreFiles.createDirectoryIfNotExists(super.dataDirectory.resolve("tracks"));
// Listen for file changes.
FileWatcher watcher = this.plugin.getFileWatcher().orElse(null);

View File

@ -38,5 +38,14 @@ public final class MoreFiles {
return path;
}
public static Path createDirectoryIfNotExists(Path path) throws IOException {
if (Files.exists(path) && Files.isDirectory(path)) {
return path;
}
Files.createDirectory(path);
return path;
}
private MoreFiles() {}
}