Add resource (sql script) validation in Initializer.java
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
package com.seibel.distanthorizons.core;
|
||||
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.sql.DatabaseUpdater;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import com.seibel.distanthorizons.core.world.DhApiWorldProxy;
|
||||
@@ -35,6 +36,8 @@ import net.jpountz.lz4.LZ4Compressor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/** Handles first time Core setup. */
|
||||
public class Initializer
|
||||
{
|
||||
@@ -57,6 +60,21 @@ public class Initializer
|
||||
throw e;
|
||||
}
|
||||
|
||||
// confirm the resource directory is present
|
||||
try
|
||||
{
|
||||
int scriptCount = DatabaseUpdater.getAutoUpdateScriptCount();
|
||||
if (scriptCount == 0)
|
||||
{
|
||||
throw new NullPointerException("No auto update scripts found, but no error thrown. This might mean the script list file is corrupted or empty.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.fatal("Critical programmer error: Can't read SQL Scripts resource folder is either missing or malformed. Error: [" + e.getMessage() + "].");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
CompleteFullDataSourceLoader unused2 = new CompleteFullDataSourceLoader(); // Auto register into the loader system
|
||||
|
||||
@@ -222,6 +222,18 @@ public class DatabaseUpdater
|
||||
|
||||
|
||||
|
||||
//====================//
|
||||
// startup validation //
|
||||
//====================//
|
||||
|
||||
/**
|
||||
* Can be used to confirm the auto update scripts are in their expected folder.
|
||||
* Will throw an exception if the scripts are missing or malformed.
|
||||
*/
|
||||
public static int getAutoUpdateScriptCount() throws NullPointerException, IOException { return getAutoUpdateScripts().size(); }
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// helper classes //
|
||||
//================//
|
||||
|
||||
Reference in New Issue
Block a user