mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-26 02:57:56 +01:00
Maybe fix problems with symlinks (#956)
This commit is contained in:
parent
2e136666be
commit
e3a783c546
@ -33,6 +33,7 @@ import me.lucko.luckperms.common.dependencies.relocation.Relocation;
|
||||
import me.lucko.luckperms.common.dependencies.relocation.RelocationHandler;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.storage.StorageType;
|
||||
import me.lucko.luckperms.common.utils.MoreFiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -82,7 +83,7 @@ public class DependencyManager {
|
||||
private Path getSaveDirectory() {
|
||||
Path saveDirectory = this.plugin.getBootstrap().getDataDirectory().resolve("lib");
|
||||
try {
|
||||
Files.createDirectories(saveDirectory);
|
||||
MoreFiles.createDirectoriesIfNotExists(saveDirectory);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Unable to create lib directory", e);
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ import ninja.leaping.configurate.SimpleConfigurationNode;
|
||||
import ninja.leaping.configurate.Types;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -132,7 +131,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
|
||||
@Override
|
||||
public void init() throws IOException {
|
||||
this.dataDirectory = this.plugin.getBootstrap().getDataDirectory().resolve(this.dataDirectoryName);
|
||||
Files.createDirectories(this.dataDirectory);
|
||||
MoreFiles.createDirectoriesIfNotExists(this.dataDirectory);
|
||||
|
||||
this.uuidDataFile = MoreFiles.createFileIfNotExists(this.dataDirectory.resolve("uuidcache.txt"));
|
||||
this.uuidCache.load(this.uuidDataFile);
|
||||
|
@ -39,7 +39,7 @@ public final class MoreFiles {
|
||||
}
|
||||
|
||||
public static Path createDirectoryIfNotExists(Path path) throws IOException {
|
||||
if (Files.exists(path) && Files.isDirectory(path)) {
|
||||
if (Files.exists(path) && (Files.isDirectory(path) || Files.isSymbolicLink(path))) {
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -47,5 +47,14 @@ public final class MoreFiles {
|
||||
return path;
|
||||
}
|
||||
|
||||
public static Path createDirectoriesIfNotExists(Path path) throws IOException {
|
||||
if (Files.exists(path) && (Files.isDirectory(path) || Files.isSymbolicLink(path))) {
|
||||
return path;
|
||||
}
|
||||
|
||||
Files.createDirectories(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
private MoreFiles() {}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
|
||||
import me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader;
|
||||
import me.lucko.luckperms.common.plugin.SchedulerAdapter;
|
||||
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
|
||||
import me.lucko.luckperms.common.utils.MoreFiles;
|
||||
import me.lucko.luckperms.sponge.utils.VersionData;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -53,7 +54,6 @@ import org.spongepowered.api.scheduler.SynchronousExecutor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -242,7 +242,7 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
|
||||
public Path getDataDirectory() {
|
||||
Path dataDirectory = this.game.getGameDirectory().toAbsolutePath().resolve("luckperms");
|
||||
try {
|
||||
Files.createDirectories(dataDirectory);
|
||||
MoreFiles.createDirectoriesIfNotExists(dataDirectory);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
||||
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
||||
import me.lucko.luckperms.common.treeview.PermissionRegistry;
|
||||
import me.lucko.luckperms.common.utils.MoreFiles;
|
||||
import me.lucko.luckperms.sponge.calculators.SpongeCalculatorFactory;
|
||||
import me.lucko.luckperms.sponge.commands.SpongeMainCommand;
|
||||
import me.lucko.luckperms.sponge.contexts.SpongeContextManager;
|
||||
@ -223,7 +224,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
Path path = this.bootstrap.getConfigPath().resolve("luckperms.conf");
|
||||
if (!Files.exists(path)) {
|
||||
try {
|
||||
Files.createDirectories(this.bootstrap.getConfigPath());
|
||||
MoreFiles.createDirectoriesIfNotExists(this.bootstrap.getConfigPath());
|
||||
try (InputStream is = getClass().getClassLoader().getResourceAsStream("luckperms.conf")) {
|
||||
Files.copy(is, path);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
import me.lucko.luckperms.common.utils.MoreFiles;
|
||||
import me.lucko.luckperms.sponge.service.model.LPPermissionService;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -101,7 +102,7 @@ public class SubjectStorage {
|
||||
private Path resolveFile(String collectionIdentifier, String subjectIdentifier) {
|
||||
Path collection = this.container.resolve(collectionIdentifier);
|
||||
try {
|
||||
Files.createDirectories(collection);
|
||||
MoreFiles.createDirectoriesIfNotExists(collection);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -128,7 +129,7 @@ public class SubjectStorage {
|
||||
* @throws IOException if the write fails
|
||||
*/
|
||||
public void saveToFile(SubjectDataContainer container, Path file) throws IOException {
|
||||
Files.createDirectories(file.getParent());
|
||||
MoreFiles.createDirectoriesIfNotExists(file.getParent());
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) {
|
||||
this.gson.toJson(container.serialize(), writer);
|
||||
writer.flush();
|
||||
|
Loading…
Reference in New Issue
Block a user