Move mock path determining to the dataDirectory method

This commit is contained in:
Vankka 2022-01-29 15:33:00 +02:00
parent ebe072858e
commit 88ef85c65e
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0

View File

@ -43,16 +43,14 @@ public class MockDiscordSRV extends AbstractDiscordSRV<MainConfig, ConnectionCon
private final Scheduler scheduler = new StandardScheduler(this);
private final Logger logger = JavaLoggerImpl.getRoot();
private final Path path;
private Path path;
public static void main(String[] args) {
new MockDiscordSRV();
}
public MockDiscordSRV() {
load();
Path path = Paths.get("/tmp/discordsrv-test");
try {
path = Files.createTempDirectory("discordsrv-test");
} catch (IOException ignored) {}
this.path = path;
}
@Override
@ -62,6 +60,14 @@ public class MockDiscordSRV extends AbstractDiscordSRV<MainConfig, ConnectionCon
@Override
public Path dataDirectory() {
if (this.path == null) {
Path path = Paths.get("/tmp/discordsrv-test");
try {
path = Files.createTempDirectory("discordsrv-test");
} catch (IOException ignored) {}
this.path = path;
}
return path;
}