diff --git a/src/main/java/net/szum123321/textile_backup/Globals.java b/src/main/java/net/szum123321/textile_backup/Globals.java index cf642fb..8d33251 100644 --- a/src/main/java/net/szum123321/textile_backup/Globals.java +++ b/src/main/java/net/szum123321/textile_backup/Globals.java @@ -28,6 +28,7 @@ import org.apache.commons.io.FileUtils; import java.nio.file.Files; import java.nio.file.Path; import java.time.format.DateTimeFormatter; +import java.util.Objects; import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -39,7 +40,7 @@ public class Globals { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); public final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss"); - private ExecutorService executorService = Executors.newSingleThreadExecutor(); + private ExecutorService executorService = null;// = Executors.newSingleThreadExecutor(); public final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true); public boolean disableWatchdog = false; private boolean disableTMPFiles = false; @@ -51,7 +52,7 @@ public class Globals { public ExecutorService getQueueExecutor() { return executorService; } public void resetQueueExecutor() { - if(!executorService.isShutdown()) return; + if(Objects.nonNull(executorService) && !executorService.isShutdown()) return; executorService = Executors.newSingleThreadExecutor(); } diff --git a/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java index 7b6adee..e184aab 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java @@ -24,8 +24,9 @@ import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.config.ConfigHelper; import net.szum123321.textile_backup.core.ActionInitiator; import net.szum123321.textile_backup.core.Cleanup; -import net.szum123321.textile_backup.core.create.compressors.*; import net.szum123321.textile_backup.core.Utilities; +import net.szum123321.textile_backup.core.create.compressors.ParallelZipCompressor; +import net.szum123321.textile_backup.core.create.compressors.ZipCompressor; import net.szum123321.textile_backup.core.create.compressors.tar.AbstractTarArchiver; import net.szum123321.textile_backup.core.create.compressors.tar.ParallelBZip2Compressor; import net.szum123321.textile_backup.core.create.compressors.tar.ParallelGzipCompressor; @@ -86,11 +87,11 @@ public class MakeBackupRunnable implements Runnable { switch (config.get().format) { case ZIP -> { if (coreCount > 1 && !Globals.INSTANCE.disableTMPFS()) { - ParallelZipCompressor.getInstance().createArchive(world, outFile, context, coreCount); log.trace("Using PARALLEL Zip Compressor. Threads: {}", coreCount); + ParallelZipCompressor.getInstance().createArchive(world, outFile, context, coreCount); } else { - ZipCompressor.getInstance().createArchive(world, outFile, context, coreCount); log.trace("Using REGULAR Zip Compressor."); + ZipCompressor.getInstance().createArchive(world, outFile, context, coreCount); } } case BZIP2 -> ParallelBZip2Compressor.getInstance().createArchive(world, outFile, context, coreCount); @@ -113,7 +114,8 @@ public class MakeBackupRunnable implements Runnable { } else { log.sendInfoAL(context, "Done!"); } - } catch (IOException e) { + } catch (Throwable e) { + //ExecutorService swallows exception, so I need to catch everythin log.error("An exception occurred when trying to create new backup file!", e); if(context.initiator() == ActionInitiator.Player)