Added more accurate detection of insufficient /tmp
parent
eb6f4fdb10
commit
50e465fc17
|
@ -36,4 +36,5 @@ public class Statics {
|
|||
public static boolean disableWatchdog = false;
|
||||
public static AwaitThread restoreAwaitThread = null;
|
||||
public static Optional<File> untouchableFile = Optional.empty();
|
||||
public static boolean disableTMPFiles = false;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.szum123321.textile_backup.commands.restore.RestoreBackupCommand;
|
|||
import net.szum123321.textile_backup.config.ConfigHelper;
|
||||
import net.szum123321.textile_backup.config.ConfigPOJO;
|
||||
import net.szum123321.textile_backup.core.ActionInitiator;
|
||||
import net.szum123321.textile_backup.core.Utilities;
|
||||
import net.szum123321.textile_backup.core.create.BackupContext;
|
||||
import net.szum123321.textile_backup.core.create.BackupHelper;
|
||||
import net.szum123321.textile_backup.core.create.BackupScheduler;
|
||||
|
@ -59,9 +60,11 @@ public class TextileBackup implements ModInitializer {
|
|||
|
||||
ServerTickEvents.END_SERVER_TICK.register(new BackupScheduler()::tick);
|
||||
|
||||
//Restart Executor Service in singleplayer
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(ignored -> {
|
||||
//Restart Executor Service in single-player
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(server -> {
|
||||
if(Statics.executorService.isShutdown()) Statics.executorService = Executors.newSingleThreadExecutor();
|
||||
|
||||
Utilities.updateTMPFSFlag(server);
|
||||
});
|
||||
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(server -> {
|
||||
|
|
|
@ -80,6 +80,15 @@ public class Utilities {
|
|||
return path;
|
||||
}
|
||||
|
||||
public static boolean updateTMPFSFlag(MinecraftServer server) {
|
||||
Statics.disableTMPFiles = (FileUtils.sizeOfDirectory(Utilities.getWorldFolder(server)) >=
|
||||
(new File(System.getProperty("java.io.tmpdir"))).getFreeSpace());
|
||||
|
||||
if(Statics.disableTMPFiles) log.warn("Not enough space left in tmp directory!\n Might cause: https://github.com/Szum123321/textile_backup/wiki/ZIP-Problems");
|
||||
|
||||
return Statics.disableTMPFiles;
|
||||
}
|
||||
|
||||
public static void disableWorldSaving(MinecraftServer server) {
|
||||
for (ServerWorld serverWorld : server.getWorlds()) {
|
||||
if (serverWorld != null && !serverWorld.savingDisabled)
|
||||
|
|
|
@ -92,7 +92,7 @@ public class MakeBackupRunnable implements Runnable {
|
|||
|
||||
switch (config.get().format) {
|
||||
case ZIP -> {
|
||||
if (coreCount > 1)
|
||||
if (coreCount > 1 && !Statics.disableTMPFiles)
|
||||
ParallelZipCompressor.getInstance().createArchive(world, outFile, context, coreCount);
|
||||
else
|
||||
ZipCompressor.getInstance().createArchive(world, outFile, context, coreCount);
|
||||
|
|
Loading…
Reference in New Issue