Added enable exceptions if data folder or config file can't be created.

This commit is contained in:
Rsl1122 2018-05-25 11:31:40 +03:00
parent d9f8d09607
commit 89bac474a7

View File

@ -62,11 +62,12 @@ public class FileSystem implements SubSystem {
@Override @Override
public void enable() throws EnableException { public void enable() throws EnableException {
dataFolder.mkdirs(); Verify.isTrue((dataFolder.exists() && dataFolder.isDirectory()) || dataFolder.mkdirs(),
() -> new EnableException("Could not create data folder at " + dataFolder.getAbsolutePath()));
try { try {
if (configFile.exists()) { Verify.isTrue((configFile.exists() && configFile.isFile()) || configFile.createNewFile(),
configFile.createNewFile(); () -> new EnableException("Could not create config file at " + configFile.getAbsolutePath()));
}
RunnableFactory.createNew(new LogsFolderCleanTask(Log.getLogsFolder())) RunnableFactory.createNew(new LogsFolderCleanTask(Log.getLogsFolder()))
.runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 30L); .runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 30L);
} catch (IOException e) { } catch (IOException e) {