From b7da7dbc6f97077276f3facb9bdccd09fcb11d0d Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 30 Aug 2022 01:15:56 +0200 Subject: [PATCH 01/24] Replaced Statics with Globals - now a singleton Moved updateTMPFSFlag from Utilities to Statics/Globals Added proper shutdown procedure for executorService (shutdownQueueExecutor) - should repair #37 Refactored some commands --- .../szum123321/textile_backup/Globals.java | 108 ++++++++++++++++++ .../szum123321/textile_backup/Statics.java | 40 ------- .../textile_backup/TextileBackup.java | 12 +- .../commands/FileSuggestionProvider.java | 6 +- .../commands/create/StartBackupCommand.java | 34 +++--- .../commands/manage/DeleteCommand.java | 6 +- .../commands/restore/KillRestoreCommand.java | 35 +++--- .../restore/RestoreBackupCommand.java | 67 +++++------ .../textile_backup/core/Utilities.java | 30 +---- .../core/create/BackupHelper.java | 4 +- .../core/create/BackupScheduler.java | 6 +- .../core/create/MakeBackupRunnable.java | 12 +- .../core/restore/RestoreBackupRunnable.java | 6 +- .../core/restore/RestoreHelper.java | 8 +- .../mixin/DedicatedServerWatchdogMixin.java | 4 +- 15 files changed, 210 insertions(+), 168 deletions(-) create mode 100644 src/main/java/net/szum123321/textile_backup/Globals.java delete mode 100644 src/main/java/net/szum123321/textile_backup/Statics.java diff --git a/src/main/java/net/szum123321/textile_backup/Globals.java b/src/main/java/net/szum123321/textile_backup/Globals.java new file mode 100644 index 0000000..7172c2d --- /dev/null +++ b/src/main/java/net/szum123321/textile_backup/Globals.java @@ -0,0 +1,108 @@ +/* + * A simple backup mod for Fabric + * Copyright (C) 2022 Szum123321 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.szum123321.textile_backup; + +import net.minecraft.server.MinecraftServer; +import net.szum123321.textile_backup.core.Utilities; +import net.szum123321.textile_backup.core.create.MakeBackupRunnable; +import net.szum123321.textile_backup.core.restore.AwaitThread; +import org.apache.commons.io.FileUtils; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.format.DateTimeFormatter; +import java.util.Optional; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + +public class Globals { + public static final Globals INSTANCE = new Globals(); + public final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss"); + + private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); + + private ExecutorService executorService = Executors.newSingleThreadExecutor(); + public final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true); + + public boolean disableWatchdog = false; + private boolean disableTMPFiles = false; + + private AwaitThread restoreAwaitThread = null; + private Path lockedPath = null; + + private Globals() {} + + public ExecutorService getQueueExecutor() { return executorService; } + + public void resetQueueExecutor() { + if(!executorService.isShutdown()) return; + executorService = Executors.newSingleThreadExecutor(); + } + + public void shutdownQueueExecutor(long timeout) { + if(executorService.isShutdown()) return; + executorService.shutdown(); + + try { + if(!executorService.awaitTermination(timeout, TimeUnit.MICROSECONDS)) { + log.error("Timeout occurred while waiting for currently running backups to finish!"); + executorService.shutdownNow().stream() + .filter(r -> r instanceof MakeBackupRunnable) + .map(r -> (MakeBackupRunnable)r) + .forEach(r -> log.error("Dropping: {}", r.toString())); + if(!executorService.awaitTermination(1000, TimeUnit.MICROSECONDS)) + log.error("Couldn't shut down the executor!"); + } + } catch (InterruptedException e) { + log.error("An exception occurred!", e); + } + + } + + public Optional getAwaitThread() { return Optional.ofNullable(restoreAwaitThread); } + + public void setAwaitThread(AwaitThread th) { restoreAwaitThread = th; } + + + public Optional getLockedFile() { return Optional.ofNullable(lockedPath); } + public void setLockedFile(Path p) { lockedPath = p; } + + public boolean disableTMPFS() { return disableTMPFiles; } + public void updateTMPFSFlag(MinecraftServer server) { + disableTMPFiles = false; + Path tmp_dir = Path.of(System.getProperty("java.io.tmpdir")); + if( + FileUtils.sizeOfDirectory(Utilities.getWorldFolder(server).toFile()) >= + tmp_dir.toFile().getUsableSpace() + ) { + log.error("Not enough space left in TMP directory! ({})", tmp_dir); + disableTMPFiles = true; + } + + if(!Files.isWritable(tmp_dir)) { + log.error("TMP filesystem ({}) is read-only!", tmp_dir); + disableTMPFiles = true; + } + + if(disableTMPFiles) log.error("Might cause: https://github.com/Szum123321/textile_backup/wiki/ZIP-Problems"); + } +} diff --git a/src/main/java/net/szum123321/textile_backup/Statics.java b/src/main/java/net/szum123321/textile_backup/Statics.java deleted file mode 100644 index 9a98ebb..0000000 --- a/src/main/java/net/szum123321/textile_backup/Statics.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * A simple backup mod for Fabric - * Copyright (C) 2020 Szum123321 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.szum123321.textile_backup; - -import net.szum123321.textile_backup.core.restore.AwaitThread; - -import java.nio.file.Path; -import java.time.format.DateTimeFormatter; -import java.util.Optional; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicBoolean; - -public class Statics { - public final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss"); - - public static ExecutorService executorService = Executors.newSingleThreadExecutor(); - - public static final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true); - public static boolean disableWatchdog = false; - public static AwaitThread restoreAwaitThread = null; - public static Optional untouchableFile = Optional.empty(); - public static boolean disableTMPFiles = false; -} diff --git a/src/main/java/net/szum123321/textile_backup/TextileBackup.java b/src/main/java/net/szum123321/textile_backup/TextileBackup.java index f609182..d2c40e2 100644 --- a/src/main/java/net/szum123321/textile_backup/TextileBackup.java +++ b/src/main/java/net/szum123321/textile_backup/TextileBackup.java @@ -38,13 +38,10 @@ 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; -import java.util.concurrent.Executors; - public class TextileBackup implements ModInitializer { public static final String MOD_NAME = "Textile Backup"; public static final String MOD_ID = "textile_backup"; @@ -62,15 +59,14 @@ public class TextileBackup implements ModInitializer { //Restart Executor Service in single-player ServerLifecycleEvents.SERVER_STARTING.register(server -> { - if(Statics.executorService.isShutdown()) Statics.executorService = Executors.newSingleThreadExecutor(); - - Utilities.updateTMPFSFlag(server); + Globals.INSTANCE.resetQueueExecutor(); + Globals.INSTANCE.updateTMPFSFlag(server); }); ServerLifecycleEvents.SERVER_STOPPED.register(server -> { - Statics.executorService.shutdown(); + Globals.INSTANCE.shutdownQueueExecutor(60000); - if (config.get().shutdownBackup && Statics.globalShutdownBackupFlag.get()) { + if (config.get().shutdownBackup && Globals.INSTANCE.globalShutdownBackupFlag.get()) { BackupHelper.create( BackupContext.Builder .newBackupContextBuilder() diff --git a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java index 9ebaaf1..7cfa439 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java +++ b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java @@ -25,7 +25,7 @@ import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import net.minecraft.server.command.ServerCommandSource; -import net.szum123321.textile_backup.Statics; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.core.Utilities; import net.szum123321.textile_backup.core.restore.RestoreHelper; @@ -39,11 +39,11 @@ public final class FileSuggestionProvider implements SuggestionProvider getSuggestions(CommandContext ctx, SuggestionsBuilder builder) throws CommandSyntaxException { + public CompletableFuture getSuggestions(CommandContext ctx, SuggestionsBuilder builder) { String remaining = builder.getRemaining(); for (RestoreHelper.RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getServer())) { - String formattedCreationTime = file.getCreationTime().format(Statics.defaultDateTimeFormatter); + String formattedCreationTime = file.getCreationTime().format(Globals.defaultDateTimeFormatter); if (formattedCreationTime.startsWith(remaining)) { if (Utilities.wasSentByPlayer(ctx.getSource())) { //was typed by player diff --git a/src/main/java/net/szum123321/textile_backup/commands/create/StartBackupCommand.java b/src/main/java/net/szum123321/textile_backup/commands/create/StartBackupCommand.java index f7cafe0..cf5f58e 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/create/StartBackupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/create/StartBackupCommand.java @@ -22,7 +22,7 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.szum123321.textile_backup.Statics; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.core.create.BackupContext; @@ -41,23 +41,21 @@ public class StartBackupCommand { } private static int execute(ServerCommandSource source, @Nullable String comment) { - if(!Statics.executorService.isShutdown()) { - try { - Statics.executorService.submit( - BackupHelper.create( - BackupContext.Builder - .newBackupContextBuilder() - .setCommandSource(source) - .setComment(comment) - .guessInitiator() - .saveServer() - .build() - ) - ); - } catch (Exception e) { - log.error("Something went wrong while executing command!", e); - throw e; - } + try { + Globals.INSTANCE.getQueueExecutor().submit( + BackupHelper.create( + BackupContext.Builder + .newBackupContextBuilder() + .setCommandSource(source) + .setComment(comment) + .guessInitiator() + .saveServer() + .build() + ) + ); + } catch (Exception e) { + log.error("Something went wrong while executing command!", e); + throw e; } return 1; diff --git a/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java b/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java index c41d1cf..7b03810 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java @@ -23,10 +23,10 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.commands.CommandExceptions; -import net.szum123321.textile_backup.Statics; import net.szum123321.textile_backup.commands.FileSuggestionProvider; import net.szum123321.textile_backup.core.Utilities; @@ -52,7 +52,7 @@ public class DeleteCommand { LocalDateTime dateTime; try { - dateTime = LocalDateTime.from(Statics.defaultDateTimeFormatter.parse(fileName)); + dateTime = LocalDateTime.from(Globals.defaultDateTimeFormatter.parse(fileName)); } catch (DateTimeParseException e) { throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e); } @@ -63,7 +63,7 @@ public class DeleteCommand { stream.filter(Utilities::isValidBackup) .filter(file -> Utilities.getFileCreationTime(file).orElse(LocalDateTime.MIN).equals(dateTime)) .findFirst().ifPresent(file -> { - if(Statics.untouchableFile.isEmpty() || !Statics.untouchableFile.get().equals(file)) { + if(Globals.INSTANCE.getLockedFile().filter(p -> p == file).isEmpty()) { try { Files.delete(file); log.sendInfo(source, "File {} successfully deleted!", file); diff --git a/src/main/java/net/szum123321/textile_backup/commands/restore/KillRestoreCommand.java b/src/main/java/net/szum123321/textile_backup/commands/restore/KillRestoreCommand.java index e764d62..f0578a0 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/restore/KillRestoreCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/restore/KillRestoreCommand.java @@ -21,33 +21,36 @@ package net.szum123321.textile_backup.commands.restore; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.szum123321.textile_backup.Statics; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.core.Utilities; - -import java.util.Optional; +import net.szum123321.textile_backup.core.restore.AwaitThread; public class KillRestoreCommand { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); public static LiteralArgumentBuilder register() { return CommandManager.literal("killR") .executes(ctx -> { - if(Statics.restoreAwaitThread != null && Statics.restoreAwaitThread.isAlive()) { - Statics.restoreAwaitThread.interrupt(); - Statics.globalShutdownBackupFlag.set(true); - Statics.untouchableFile = Optional.empty(); - - log.info("{} cancelled backup restoration.", Utilities.wasSentByPlayer(ctx.getSource()) ? - "Player: " + ctx.getSource().getName() : - "SERVER" - ); - - if(Utilities.wasSentByPlayer(ctx.getSource())) - log.sendInfo(ctx.getSource(), "Backup restoration successfully stopped."); - } else { + if(Globals.INSTANCE.getAwaitThread().filter(Thread::isAlive).isEmpty()) { log.sendInfo(ctx.getSource(), "Failed to stop backup restoration"); + return -1; } + + AwaitThread thread = Globals.INSTANCE.getAwaitThread().get(); + + thread.interrupt(); + Globals.INSTANCE.globalShutdownBackupFlag.set(true); + Globals.INSTANCE.setLockedFile(null); + + log.info("{} cancelled backup restoration.", Utilities.wasSentByPlayer(ctx.getSource()) ? + "Player: " + ctx.getSource().getName() : + "SERVER" + ); + + if(Utilities.wasSentByPlayer(ctx.getSource())) + log.sendInfo(ctx.getSource(), "Backup restoration successfully stopped."); + return 1; }); } diff --git a/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java b/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java index 85d984b..a339735 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java @@ -24,10 +24,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.commands.CommandExceptions; -import net.szum123321.textile_backup.Statics; import net.szum123321.textile_backup.commands.FileSuggestionProvider; import net.szum123321.textile_backup.core.restore.RestoreContext; import net.szum123321.textile_backup.core.restore.RestoreHelper; @@ -70,41 +70,42 @@ public class RestoreBackupCommand { } private static int execute(String file, @Nullable String comment, ServerCommandSource source) throws CommandSyntaxException { - if(Statics.restoreAwaitThread == null || (Statics.restoreAwaitThread != null && !Statics.restoreAwaitThread.isAlive())) { - LocalDateTime dateTime; - - try { - dateTime = LocalDateTime.from(Statics.defaultDateTimeFormatter.parse(file)); - } catch (DateTimeParseException e) { - throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e); - } - - Optional backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getServer()); - - if(backupFile.isPresent()) { - log.info("Found file to restore {}", backupFile.get().getFile().getFileName().toString()); - } else { - log.sendInfo(source, "No file created on {} was found!", dateTime.format(Statics.defaultDateTimeFormatter)); - - return 0; - } - - Statics.restoreAwaitThread = RestoreHelper.create( - RestoreContext.Builder.newRestoreContextBuilder() - .setCommandSource(source) - .setFile(backupFile.get()) - .setComment(comment) - .build() - ); - - Statics.restoreAwaitThread.start(); - - return 1; - } else { + if(Globals.INSTANCE.getAwaitThread().filter(Thread::isAlive).isPresent()) { log.sendInfo(source, "Someone has already started another restoration."); - return 0; + return -1; } + + LocalDateTime dateTime; + + try { + dateTime = LocalDateTime.from(Globals.defaultDateTimeFormatter.parse(file)); + } catch (DateTimeParseException e) { + throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e); + } + + Optional backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getServer()); + + if(backupFile.isPresent()) { + log.info("Found file to restore {}", backupFile.get().getFile().getFileName().toString()); + } else { + log.sendInfo(source, "No file created on {} was found!", dateTime.format(Globals.defaultDateTimeFormatter)); + return -1; + } + + Globals.INSTANCE.setAwaitThread( + RestoreHelper.create( + RestoreContext.Builder.newRestoreContextBuilder() + .setCommandSource(source) + .setFile(backupFile.get()) + .setComment(comment) + .build() + ) + ); + + Globals.INSTANCE.getAwaitThread().get().start(); + + return 1; } } diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index 5913e04..c38304d 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -25,13 +25,12 @@ import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.world.World; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.config.ConfigHelper; import net.szum123321.textile_backup.config.ConfigPOJO; -import net.szum123321.textile_backup.Statics; import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor; -import org.apache.commons.io.FileUtils; import org.apache.commons.io.file.SimplePathVisitor; import org.jetbrains.annotations.NotNull; @@ -75,7 +74,7 @@ public class Utilities { } public static Path getBackupRootPath(String worldName) { - Path path = Path.of(config.get().path).toAbsolutePath(); + Path path = Path.of(config.get().backupDirectoryPath).toAbsolutePath(); if (config.get().perWorldBackup) path = path.resolve(worldName); @@ -104,25 +103,6 @@ public class Utilities { }); } - public static void updateTMPFSFlag(MinecraftServer server) { - boolean flag = false; - Path tmp_dir = Path.of(System.getProperty("java.io.tmpdir")); - if( - FileUtils.sizeOfDirectory(Utilities.getWorldFolder(server).toFile()) >= - tmp_dir.toFile().getUsableSpace() - ) { - log.error("Not enough space left in TMP directory! ({})", tmp_dir); - flag = true; - } - //!Files.isWritable(tmp_dir.resolve("test_txb_file_2137")) - Unsure why this was resolving to a file that isn't being created (at least not in Windows) - if(!Files.isWritable(tmp_dir)) { - log.error("TMP filesystem ({}) is read-only!", tmp_dir); - flag = true; - } - - if((Statics.disableTMPFiles = flag)) log.error("Might cause: https://github.com/Szum123321/textile_backup/wiki/ZIP-Problems"); - } - public static void disableWorldSaving(MinecraftServer server) { for (ServerWorld serverWorld : server.getWorlds()) { if (serverWorld != null && !serverWorld.savingDisabled) @@ -181,7 +161,7 @@ public class Utilities { try { return Optional.of( LocalDateTime.from( - Utilities.getBackupDateTimeFormatter().parse( + Globals.defaultDateTimeFormatter.parse( file.getFileName().toString().split(fileExtension)[0].split("#")[0] ))); } catch (Exception ignored) {} @@ -205,10 +185,6 @@ public class Utilities { return DateTimeFormatter.ofPattern(config.get().dateTimeFormat); } - public static DateTimeFormatter getBackupDateTimeFormatter() { - return Statics.defaultDateTimeFormatter; - } - public static String formatDuration(Duration duration) { DateTimeFormatter formatter; diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java index 04d54ea..a61fdd2 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java @@ -19,7 +19,7 @@ package net.szum123321.textile_backup.core.create; import net.minecraft.server.command.ServerCommandSource; -import net.szum123321.textile_backup.Statics; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.config.ConfigHelper; @@ -172,7 +172,7 @@ public class BackupHelper { //1 -> ok, 0 -> err private static int deleteFile(Path f, ServerCommandSource ctx) { - if(Statics.untouchableFile.isEmpty()|| !Statics.untouchableFile.get().equals(f)) { + if(Globals.INSTANCE.getLockedFile().filter(p -> p == f).isEmpty()) { try { Files.delete(f); log.sendInfoAL(ctx, "Deleting: {}", f); diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java index b2ca19e..10d1be3 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java @@ -19,7 +19,7 @@ package net.szum123321.textile_backup.core.create; import net.minecraft.server.MinecraftServer; -import net.szum123321.textile_backup.Statics; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.config.ConfigHelper; import net.szum123321.textile_backup.core.ActionInitiator; @@ -43,7 +43,7 @@ public class BackupScheduler { if(config.get().doBackupsOnEmptyServer || server.getPlayerManager().getCurrentPlayerCount() > 0) { if(scheduled) { if(nextBackup <= now) { - Statics.executorService.submit( + Globals.INSTANCE.getQueueExecutor().submit( BackupHelper.create( BackupContext.Builder .newBackupContextBuilder() @@ -62,7 +62,7 @@ public class BackupScheduler { } } else if(!config.get().doBackupsOnEmptyServer && server.getPlayerManager().getCurrentPlayerCount() == 0) { if(scheduled && nextBackup <= now) { - Statics.executorService.submit( + Globals.INSTANCE.getQueueExecutor().submit( BackupHelper.create( BackupContext.Builder .newBackupContextBuilder() 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 9ad6aa8..beba9b8 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 @@ -18,7 +18,7 @@ package net.szum123321.textile_backup.core.create; -import net.szum123321.textile_backup.Statics; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.config.ConfigHelper; @@ -42,7 +42,7 @@ public class MakeBackupRunnable implements Runnable { private final BackupContext context; - public MakeBackupRunnable(BackupContext context){ + public MakeBackupRunnable(BackupContext context) { this.context = context; } @@ -50,9 +50,9 @@ public class MakeBackupRunnable implements Runnable { public void run() { try { Utilities.disableWorldSaving(context.server()); - Statics.disableWatchdog = true; + Globals.INSTANCE.disableWatchdog = true; - Utilities.updateTMPFSFlag(context.server()); + Globals.INSTANCE.updateTMPFSFlag(context.server()); log.sendInfoAL(context, "Starting backup"); @@ -90,7 +90,7 @@ public class MakeBackupRunnable implements Runnable { switch (config.get().format) { case ZIP -> { - if (coreCount > 1 && !Statics.disableTMPFiles) { + if (coreCount > 1 && !Globals.INSTANCE.disableTMPFS()) { ParallelZipCompressor.getInstance().createArchive(world, outFile, context, coreCount); log.trace("Using PARALLEL Zip Compressor. Threads: {}", coreCount); } else { @@ -120,7 +120,7 @@ public class MakeBackupRunnable implements Runnable { } } finally { Utilities.enableWorldSaving(context.server()); - Statics.disableWatchdog = false; + Globals.INSTANCE.disableWatchdog = false; } } diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java index a803d93..7de61ef 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java @@ -18,13 +18,13 @@ package net.szum123321.textile_backup.core.restore; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; 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.LivingServer; -import net.szum123321.textile_backup.Statics; import net.szum123321.textile_backup.core.Utilities; import net.szum123321.textile_backup.core.create.BackupContext; import net.szum123321.textile_backup.core.create.BackupHelper; @@ -47,7 +47,7 @@ public class RestoreBackupRunnable implements Runnable { @Override public void run() { - Statics.globalShutdownBackupFlag.set(false); + Globals.INSTANCE.globalShutdownBackupFlag.set(false); log.info("Shutting down server..."); @@ -95,7 +95,7 @@ public class RestoreBackupRunnable implements Runnable { } //in case we're playing on client - Statics.globalShutdownBackupFlag.set(true); + Globals.INSTANCE.globalShutdownBackupFlag.set(true); log.info("Done!"); } diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java index 856f692..085dc6d 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java @@ -19,11 +19,11 @@ package net.szum123321.textile_backup.core.restore; import net.minecraft.server.MinecraftServer; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.config.ConfigHelper; import net.szum123321.textile_backup.config.ConfigPOJO; -import net.szum123321.textile_backup.Statics; import net.szum123321.textile_backup.core.ActionInitiator; import net.szum123321.textile_backup.core.Utilities; import org.jetbrains.annotations.NotNull; @@ -45,7 +45,7 @@ public class RestoreHelper { Optional optionalFile; try (Stream stream = Files.list(root)) { - optionalFile = stream + optionalFile = stream .map(RestoreableFile::newInstance) .flatMap(Optional::stream) .filter(rf -> rf.getCreationTime().equals(backupTime)) @@ -54,7 +54,7 @@ public class RestoreHelper { throw new RuntimeException(e); } - Statics.untouchableFile = optionalFile.map(RestoreableFile::getFile); + optionalFile.ifPresent(r -> Globals.INSTANCE.setLockedFile(r.getFile())); return optionalFile; } @@ -138,7 +138,7 @@ public class RestoreHelper { } public String toString() { - return this.getCreationTime().format(Statics.defaultDateTimeFormatter) + (comment != null ? "#" + comment : ""); + return this.getCreationTime().format(Globals.defaultDateTimeFormatter) + (comment != null ? "#" + comment : ""); } } } \ No newline at end of file diff --git a/src/main/java/net/szum123321/textile_backup/mixin/DedicatedServerWatchdogMixin.java b/src/main/java/net/szum123321/textile_backup/mixin/DedicatedServerWatchdogMixin.java index d6b37ac..2b9f0bb 100644 --- a/src/main/java/net/szum123321/textile_backup/mixin/DedicatedServerWatchdogMixin.java +++ b/src/main/java/net/szum123321/textile_backup/mixin/DedicatedServerWatchdogMixin.java @@ -20,7 +20,7 @@ package net.szum123321.textile_backup.mixin; import net.minecraft.server.dedicated.DedicatedServerWatchdog; import net.minecraft.util.Util; -import net.szum123321.textile_backup.Statics; +import net.szum123321.textile_backup.Globals; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; @@ -30,6 +30,6 @@ public class DedicatedServerWatchdogMixin { @ModifyVariable(method = "run()V", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/Util;getMeasuringTimeMs()J"), ordinal = 0, name = "l") private long redirectedCall(long original) { - return Statics.disableWatchdog ? Util.getMeasuringTimeMs() : original; + return Globals.INSTANCE.disableWatchdog ? Util.getMeasuringTimeMs() : original; } } From b3a340deabb35bfdd044080b85c2926e534fd20c Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 30 Aug 2022 01:31:43 +0200 Subject: [PATCH 02/24] Separated BackupHelper into the factory and the cleanup (MakeBackupRunnableFactory & Cleanup) --- .../textile_backup/TextileBackup.java | 4 +- .../commands/create/CleanupCommand.java | 4 +- .../commands/create/StartBackupCommand.java | 4 +- .../BackupHelper.java => Cleanup.java} | 79 +++++-------------- .../core/create/BackupScheduler.java | 4 +- .../core/create/MakeBackupRunnable.java | 3 +- .../create/MakeBackupRunnableFactory.java | 72 +++++++++++++++++ .../core/restore/RestoreBackupRunnable.java | 4 +- 8 files changed, 103 insertions(+), 71 deletions(-) rename src/main/java/net/szum123321/textile_backup/core/{create/BackupHelper.java => Cleanup.java} (68%) create mode 100644 src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnableFactory.java diff --git a/src/main/java/net/szum123321/textile_backup/TextileBackup.java b/src/main/java/net/szum123321/textile_backup/TextileBackup.java index d2c40e2..81d514a 100644 --- a/src/main/java/net/szum123321/textile_backup/TextileBackup.java +++ b/src/main/java/net/szum123321/textile_backup/TextileBackup.java @@ -39,8 +39,8 @@ 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.create.BackupContext; -import net.szum123321.textile_backup.core.create.BackupHelper; import net.szum123321.textile_backup.core.create.BackupScheduler; +import net.szum123321.textile_backup.core.create.MakeBackupRunnableFactory; public class TextileBackup implements ModInitializer { public static final String MOD_NAME = "Textile Backup"; @@ -67,7 +67,7 @@ public class TextileBackup implements ModInitializer { Globals.INSTANCE.shutdownQueueExecutor(60000); if (config.get().shutdownBackup && Globals.INSTANCE.globalShutdownBackupFlag.get()) { - BackupHelper.create( + MakeBackupRunnableFactory.create( BackupContext.Builder .newBackupContextBuilder() .setServer(server) diff --git a/src/main/java/net/szum123321/textile_backup/commands/create/CleanupCommand.java b/src/main/java/net/szum123321/textile_backup/commands/create/CleanupCommand.java index 4ca516f..05dafce 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/create/CleanupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/create/CleanupCommand.java @@ -23,7 +23,7 @@ import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; -import net.szum123321.textile_backup.core.create.BackupHelper; +import net.szum123321.textile_backup.core.Cleanup; import net.szum123321.textile_backup.core.Utilities; public class CleanupCommand { @@ -38,7 +38,7 @@ public class CleanupCommand { log.sendInfo( source, "Deleted: {} files.", - BackupHelper.executeFileLimit(source, Utilities.getLevelName(source.getServer())) + Cleanup.executeFileLimit(source, Utilities.getLevelName(source.getServer())) ); return 1; diff --git a/src/main/java/net/szum123321/textile_backup/commands/create/StartBackupCommand.java b/src/main/java/net/szum123321/textile_backup/commands/create/StartBackupCommand.java index cf5f58e..830a88a 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/create/StartBackupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/create/StartBackupCommand.java @@ -26,7 +26,7 @@ import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.core.create.BackupContext; -import net.szum123321.textile_backup.core.create.BackupHelper; +import net.szum123321.textile_backup.core.create.MakeBackupRunnableFactory; import javax.annotation.Nullable; @@ -43,7 +43,7 @@ public class StartBackupCommand { private static int execute(ServerCommandSource source, @Nullable String comment) { try { Globals.INSTANCE.getQueueExecutor().submit( - BackupHelper.create( + MakeBackupRunnableFactory.create( BackupContext.Builder .newBackupContextBuilder() .setCommandSource(source) diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java similarity index 68% rename from src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java rename to src/main/java/net/szum123321/textile_backup/core/Cleanup.java index a61fdd2..e3114fa 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -1,29 +1,29 @@ /* - A simple backup mod for Fabric - Copyright (C) 2020 Szum123321 + * A simple backup mod for Fabric + * Copyright (C) 2022 Szum123321 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -package net.szum123321.textile_backup.core.create; +package net.szum123321.textile_backup.core; import net.minecraft.server.command.ServerCommandSource; import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.config.ConfigHelper; -import net.szum123321.textile_backup.core.Utilities; import java.io.IOException; import java.nio.file.Files; @@ -35,55 +35,14 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Stream; -public class BackupHelper { +public class Cleanup { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); private final static ConfigHelper config = ConfigHelper.INSTANCE; - public static Runnable create(BackupContext ctx) { - if(config.get().broadcastBackupStart) { - Utilities.notifyPlayers(ctx.server(), - "Warning! Server backup will begin shortly. You may experience some lag." - ); - } else { - log.sendInfoAL(ctx, "Warning! Server backup will begin shortly. You may experience some lag."); - } - - StringBuilder builder = new StringBuilder(); - - builder.append("Backup started "); - - builder.append(ctx.initiator().getPrefix()); - - if(ctx.startedByPlayer()) - builder.append(ctx.commandSource().getDisplayName().getString()); - else - builder.append(ctx.initiator().getName()); - - builder.append(" on: "); - builder.append(Utilities.getDateTimeFormatter().format(LocalDateTime.now())); - - log.info(builder.toString()); - - if (ctx.shouldSave()) { - log.sendInfoAL(ctx, "Saving server..."); - - ctx.server().getPlayerManager().saveAllPlayerData(); - - try { - ctx.server().save(false, true, true); - } catch (Exception e) { - log.sendErrorAL(ctx,"An exception occurred when trying to save the world!"); - } - } - - return new MakeBackupRunnable(ctx); - } - public static int executeFileLimit(ServerCommandSource ctx, String worldName) { Path root = Utilities.getBackupRootPath(worldName); int deletedFiles = 0; - if (Files.isDirectory(root) && Files.exists(root) && !isEmpty(root)) { if (config.get().maxAge > 0) { // delete files older that configured final long now = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java index 10d1be3..6ce816a 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java @@ -44,7 +44,7 @@ public class BackupScheduler { if(scheduled) { if(nextBackup <= now) { Globals.INSTANCE.getQueueExecutor().submit( - BackupHelper.create( + MakeBackupRunnableFactory.create( BackupContext.Builder .newBackupContextBuilder() .setServer(server) @@ -63,7 +63,7 @@ public class BackupScheduler { } else if(!config.get().doBackupsOnEmptyServer && server.getPlayerManager().getCurrentPlayerCount() == 0) { if(scheduled && nextBackup <= now) { Globals.INSTANCE.getQueueExecutor().submit( - BackupHelper.create( + MakeBackupRunnableFactory.create( BackupContext.Builder .newBackupContextBuilder() .setServer(server) 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 beba9b8..05e8c3a 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 @@ -23,6 +23,7 @@ import net.szum123321.textile_backup.TextileBackup; 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.tar.AbstractTarArchiver; @@ -108,7 +109,7 @@ public class MakeBackupRunnable implements Runnable { case TAR -> new AbstractTarArchiver().createArchive(world, outFile, context, coreCount); } - BackupHelper.executeFileLimit(context.commandSource(), Utilities.getLevelName(context.server())); + Cleanup.executeFileLimit(context.commandSource(), Utilities.getLevelName(context.server())); if(config.get().broadcastBackupDone) { Utilities.notifyPlayers( diff --git a/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnableFactory.java b/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnableFactory.java new file mode 100644 index 0000000..36d8eb6 --- /dev/null +++ b/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnableFactory.java @@ -0,0 +1,72 @@ +/* + * A simple backup mod for Fabric + * Copyright (C) 2022 Szum123321 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.szum123321.textile_backup.core.create; + +import net.szum123321.textile_backup.TextileBackup; +import net.szum123321.textile_backup.TextileLogger; +import net.szum123321.textile_backup.config.ConfigHelper; +import net.szum123321.textile_backup.core.Utilities; + +import java.time.LocalDateTime; + +public class MakeBackupRunnableFactory { + private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); + private final static ConfigHelper config = ConfigHelper.INSTANCE; + + public static Runnable create(BackupContext ctx) { + if(config.get().broadcastBackupStart) { + Utilities.notifyPlayers(ctx.server(), + "Warning! Server backup will begin shortly. You may experience some lag." + ); + } else { + log.sendInfoAL(ctx, "Warning! Server backup will begin shortly. You may experience some lag."); + } + + StringBuilder builder = new StringBuilder(); + + builder.append("Backup started "); + + builder.append(ctx.initiator().getPrefix()); + + if(ctx.startedByPlayer()) + builder.append(ctx.commandSource().getDisplayName().getString()); + else + builder.append(ctx.initiator().getName()); + + builder.append(" on: "); + builder.append(Utilities.getDateTimeFormatter().format(LocalDateTime.now())); + + log.info(builder.toString()); + + if (ctx.shouldSave()) { + log.sendInfoAL(ctx, "Saving server..."); + + ctx.server().getPlayerManager().saveAllPlayerData(); + + try { + ctx.server().save(false, true, true); + } catch (Exception e) { + log.sendErrorAL(ctx,"An exception occurred when trying to save the world!"); + } + } + + return new MakeBackupRunnable(ctx); + } +} diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java index 7de61ef..2f3e207 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java @@ -27,7 +27,7 @@ import net.szum123321.textile_backup.core.ActionInitiator; import net.szum123321.textile_backup.core.LivingServer; 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.MakeBackupRunnableFactory; import net.szum123321.textile_backup.core.restore.decompressors.GenericTarDecompressor; import net.szum123321.textile_backup.core.restore.decompressors.ZipDecompressor; @@ -55,7 +55,7 @@ public class RestoreBackupRunnable implements Runnable { awaitServerShutdown(); if(config.get().backupOldWorlds) { - BackupHelper.create( + MakeBackupRunnableFactory.create( BackupContext.Builder .newBackupContextBuilder() .setServer(ctx.server()) From 21cf46a56a0120b2df928adaf67085b261454fef Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 30 Aug 2022 13:28:30 +0200 Subject: [PATCH 03/24] Moved all filename paring into its own class --- .../commands/FileSuggestionProvider.java | 5 +- .../commands/manage/DeleteCommand.java | 46 +++--- .../commands/manage/ListBackupsCommand.java | 5 +- .../restore/RestoreBackupCommand.java | 3 +- .../textile_backup/core/Cleanup.java | 132 ++++++++---------- .../textile_backup/core/RestoreableFile.java | 118 ++++++++++++++++ .../textile_backup/core/Utilities.java | 86 ++---------- .../core/restore/RestoreContext.java | 7 +- .../core/restore/RestoreHelper.java | 85 ++--------- 9 files changed, 231 insertions(+), 256 deletions(-) create mode 100644 src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java diff --git a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java index 7cfa439..d7fcea5 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java +++ b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java @@ -20,12 +20,12 @@ package net.szum123321.textile_backup.commands; import com.mojang.brigadier.LiteralMessage; import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import net.minecraft.server.command.ServerCommandSource; import net.szum123321.textile_backup.Globals; +import net.szum123321.textile_backup.core.RestoreableFile; import net.szum123321.textile_backup.core.Utilities; import net.szum123321.textile_backup.core.restore.RestoreHelper; @@ -42,7 +42,7 @@ public final class FileSuggestionProvider implements SuggestionProvider getSuggestions(CommandContext ctx, SuggestionsBuilder builder) { String remaining = builder.getRemaining(); - for (RestoreHelper.RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getServer())) { + for (RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getServer())) { String formattedCreationTime = file.getCreationTime().format(Globals.defaultDateTimeFormatter); if (formattedCreationTime.startsWith(remaining)) { @@ -61,6 +61,7 @@ public final class FileSuggestionProvider implements SuggestionProvider stream = Files.list(root)) { - stream.filter(Utilities::isValidBackup) - .filter(file -> Utilities.getFileCreationTime(file).orElse(LocalDateTime.MIN).equals(dateTime)) - .findFirst().ifPresent(file -> { - if(Globals.INSTANCE.getLockedFile().filter(p -> p == file).isEmpty()) { - try { - Files.delete(file); - log.sendInfo(source, "File {} successfully deleted!", file); + RestoreableFile.applyOnFiles(root, Optional.empty(), + e -> { + log.sendError(source, "Couldn't find file by this name."); + log.sendHint(source, "Maybe try /backup list"); + }, + stream -> stream.filter(f -> f.getCreationTime().equals(dateTime)).map(RestoreableFile::getFile).findFirst() + ).ifPresent(file -> { + if(Globals.INSTANCE.getLockedFile().filter(p -> p == file).isEmpty()) { + try { + Files.delete((Path) file); + log.sendInfo(source, "File {} successfully deleted!", file); - if(Utilities.wasSentByPlayer(source)) - log.info("Player {} deleted {}.", source.getPlayer().getName(), file); - } catch (IOException e) { - log.sendError(source, "Something went wrong while deleting file!"); - } - } else { - log.sendError(source, "Couldn't delete the file because it's being restored right now."); - log.sendHint(source, "If you want to abort restoration then use: /backup killR"); + if(Utilities.wasSentByPlayer(source)) + log.info("Player {} deleted {}.", source.getPlayer().getName(), file); + } catch (IOException e) { + log.sendError(source, "Something went wrong while deleting file!"); } - }); - } catch (IOException ignored) { - log.sendError(source, "Couldn't find file by this name."); - log.sendHint(source, "Maybe try /backup list"); - } - + } else { + log.sendError(source, "Couldn't delete the file because it's being restored right now."); + log.sendHint(source, "If you want to abort restoration then use: /backup killR"); + } + } + ); return 0; } } diff --git a/src/main/java/net/szum123321/textile_backup/commands/manage/ListBackupsCommand.java b/src/main/java/net/szum123321/textile_backup/commands/manage/ListBackupsCommand.java index 42c49d9..22f363b 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/manage/ListBackupsCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/manage/ListBackupsCommand.java @@ -23,6 +23,7 @@ import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; +import net.szum123321.textile_backup.core.RestoreableFile; import net.szum123321.textile_backup.core.restore.RestoreHelper; import java.util.*; @@ -33,7 +34,7 @@ public class ListBackupsCommand { public static LiteralArgumentBuilder register() { return CommandManager.literal("list") .executes(ctx -> { StringBuilder builder = new StringBuilder(); - List backups = RestoreHelper.getAvailableBackups(ctx.getSource().getServer()); + List backups = RestoreHelper.getAvailableBackups(ctx.getSource().getServer()); if(backups.size() == 0) { builder.append("There a no backups available for this world."); @@ -42,7 +43,7 @@ public class ListBackupsCommand { builder.append(backups.get(0).toString()); } else { backups.sort(null); - Iterator iterator = backups.iterator(); + Iterator iterator = backups.iterator(); builder.append("Available backups:\n"); builder.append(iterator.next()); diff --git a/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java b/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java index a339735..2446f0a 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java @@ -29,6 +29,7 @@ import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.commands.CommandExceptions; import net.szum123321.textile_backup.commands.FileSuggestionProvider; +import net.szum123321.textile_backup.core.RestoreableFile; import net.szum123321.textile_backup.core.restore.RestoreContext; import net.szum123321.textile_backup.core.restore.RestoreHelper; @@ -84,7 +85,7 @@ public class RestoreBackupCommand { throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e); } - Optional backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getServer()); + Optional backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getServer()); if(backupFile.isPresent()) { log.info("Found file to restore {}", backupFile.get().getFile().getFileName().toString()); diff --git a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java index e3114fa..f7f022e 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -19,7 +19,7 @@ package net.szum123321.textile_backup.core; -import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.command.ServerCommandSource; import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; @@ -30,7 +30,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; import java.time.ZoneOffset; -import java.util.Comparator; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Stream; @@ -43,106 +42,85 @@ public class Cleanup { Path root = Utilities.getBackupRootPath(worldName); int deletedFiles = 0; - if (Files.isDirectory(root) && Files.exists(root) && !isEmpty(root)) { - if (config.get().maxAge > 0) { // delete files older that configured - final long now = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); + if (!Files.isDirectory(root) || !Files.exists(root) || isEmpty(root)) return 0; - try(Stream stream = Files.list(root)) { - deletedFiles += stream - .filter(Utilities::isValidBackup)// We check if we can get file's creation date so that the next line won't throw an exception - .filter(f -> now - Utilities.getFileCreationTime(f).get().toEpochSecond(ZoneOffset.UTC) > config.get().maxAge) - .mapToInt(f -> deleteFile(f, ctx)) - .sum(); - } catch (IOException e) { - log.error("An exception occurred while trying to delete old files!", e); - } - } + if (config.get().maxAge > 0) { // delete files older that configured + final long now = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); - final int noToKeep = config.get().backupsToKeep > 0 ? config.get().backupsToKeep : Integer.MAX_VALUE; - final long maxSize = config.get().maxSize > 0 ? config.get().maxSize * 1024: Long.MAX_VALUE; + deletedFiles += RestoreableFile.applyOnFiles(root, 0, + e -> log.error("An exception occurred while trying to delete old files!", e), + stream -> stream.filter(f -> now - f.getCreationTime().toEpochSecond(ZoneOffset.UTC) > config.get().maxAge) + .mapToInt(f -> deleteFile(f.getFile(), ctx)) + .sum() + ); + } - AtomicInteger currentNo = new AtomicInteger(countBackups(root)); - AtomicLong currentSize = new AtomicLong(countSize(root)); + final int noToKeep = config.get().backupsToKeep > 0 ? config.get().backupsToKeep : Integer.MAX_VALUE; + final long maxSize = config.get().maxSize > 0 ? config.get().maxSize * 1024: Long.MAX_VALUE; - try(Stream stream = Files.list(root)) { - deletedFiles += stream - .filter(Utilities::isValidBackup) - .sorted(Comparator.comparing(f -> Utilities.getFileCreationTime(f).get())) + long[] counts = count(root); + + AtomicInteger currentNo = new AtomicInteger((int) counts[0]); + AtomicLong currentSize = new AtomicLong(counts[1]); + + deletedFiles += RestoreableFile.applyOnFiles(root, 0, + e -> log.error("An exception occurred while trying to delete old files!", e), + stream -> stream.sequential() .takeWhile(f -> (currentNo.get() > noToKeep) || (currentSize.get() > maxSize)) + .map(RestoreableFile::getFile) .peek(f -> { - currentNo.decrementAndGet(); try { currentSize.addAndGet(-Files.size(f)); } catch (IOException e) { currentSize.set(0); + return; } + currentNo.decrementAndGet(); }) .mapToInt(f -> deleteFile(f, ctx)) - .sum(); - } catch (IOException e) { - log.error("An exception occurred while trying to delete old files!", e); - } - } + .sum()); return deletedFiles; } - private static int countBackups(Path path) { - try(Stream stream = Files.list(path)) { - return (int) stream - .filter(Utilities::isValidBackup) - .count(); - } catch (IOException e) { - log.error("Error while counting files!", e); - } - return 0; - } + private static long[] count(Path root) { + long n = 0, size = 0; - private static long countSize(Path path) { - try(Stream stream = Files.list(path)) { - return stream - .filter(Utilities::isValidBackup) - .mapToLong(f -> { - try { - return Files.size(f); - } catch (IOException e) { - log.error("Couldn't delete a file!", e); - return 0; - } - }) - .sum(); - } catch (IOException e) { - log.error("Error while counting files!", e); - } - return 0; - } - - private static boolean isEmpty(Path path) { - if (Files.isDirectory(path)) { - try (Stream entries = Files.list(path)) { - return entries.findFirst().isEmpty(); - } catch (IOException e) { - return false; + try(Stream stream = Files.list(root)) { + var it = stream.flatMap(f -> RestoreableFile.build(f).stream()).iterator(); + while(it.hasNext()) { + var f = it.next(); + try { + size += Files.size(f.getFile()); + } catch (IOException e) { + log.error("Couldn't get size of " + f.getFile(), e); + continue; + } + n++; } + } catch (IOException e) { + log.error("Error while counting files!", e); } - return false; + return new long[]{n, size}; + } + + private static boolean isEmpty(Path root) { + if (!Files.isDirectory(root)) return false; + return RestoreableFile.applyOnFiles(root, false, e -> {}, s -> s.findFirst().isEmpty()); } //1 -> ok, 0 -> err private static int deleteFile(Path f, ServerCommandSource ctx) { - if(Globals.INSTANCE.getLockedFile().filter(p -> p == f).isEmpty()) { - try { - Files.delete(f); - log.sendInfoAL(ctx, "Deleting: {}", f); - } catch (IOException e) { - if(Utilities.wasSentByPlayer(ctx)) log.sendError(ctx, "Something went wrong while deleting: {}.", f); - log.error("Something went wrong while deleting: {}.", f, e); - return 0; - } - return 1; + if(Globals.INSTANCE.getLockedFile().filter(p -> p == f).isPresent()) return 0; + try { + Files.delete(f); + log.sendInfoAL(ctx, "Deleted: {}", f); + } catch (IOException e) { + if(Utilities.wasSentByPlayer(ctx)) log.sendError(ctx, "Something went wrong while deleting: {}.", f); + log.error("Something went wrong while deleting: {}.", f, e); + return 0; } - - return 0; + return 1; } } \ No newline at end of file diff --git a/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java new file mode 100644 index 0000000..2725470 --- /dev/null +++ b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java @@ -0,0 +1,118 @@ +/* + * A simple backup mod for Fabric + * Copyright (C) 2022 Szum123321 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package net.szum123321.textile_backup.core; + +import net.szum123321.textile_backup.Globals; +import net.szum123321.textile_backup.config.ConfigPOJO; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.FileTime; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Arrays; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Stream; + +import static java.nio.file.LinkOption.NOFOLLOW_LINKS; + +public class RestoreableFile implements Comparable { + private final Path file; + private final ConfigPOJO.ArchiveFormat archiveFormat; + private final LocalDateTime creationTime; + private final String comment; + + private RestoreableFile(Path file, ConfigPOJO.ArchiveFormat archiveFormat, LocalDateTime creationTime, String comment) { + this.file = file; + this.archiveFormat = archiveFormat; + this.creationTime = creationTime; + this.comment = comment; + } + + public static T applyOnFiles(Path root, T def, Consumer errorConsumer, Function, T> streamConsumer) { + try (Stream stream = Files.list(root)) { + return streamConsumer.apply(stream.flatMap(f -> RestoreableFile.build(f).stream())); + } catch (IOException e) { + errorConsumer.accept(e); + } + return def; + } + + public static Optional build(Path file) throws NoSuchElementException { + if(!Files.exists(file) || !Files.isRegularFile(file)) return Optional.empty(); + + String filename = file.getFileName().toString(); + + var format = Arrays.stream(ConfigPOJO.ArchiveFormat.values()) + .filter(f -> filename.endsWith(f.getCompleteString())) + .findAny() + .orElse(null); + + if(Objects.isNull(format)) return Optional.empty(); + + int parsed_pos = filename.length() - format.getCompleteString().length(); + + String comment = null; + + if(filename.contains("#")) { + comment = filename.substring(filename.indexOf("#"), parsed_pos); + parsed_pos -= comment.length() - 1; + } + + var time_string = filename.substring(0, parsed_pos); + + try { + return Optional.of(new RestoreableFile(file, format, LocalDateTime.from(Utilities.getDateTimeFormatter().parse(time_string)), comment)); + } catch (Exception ignored) {} + + try { + return Optional.of(new RestoreableFile(file, format, LocalDateTime.from(Globals.defaultDateTimeFormatter.parse(time_string)), comment)); + } catch (Exception ignored) {} + + try { + FileTime fileTime = Files.readAttributes(file, BasicFileAttributes.class, NOFOLLOW_LINKS).creationTime(); + return Optional.of(new RestoreableFile(file, format, LocalDateTime.ofInstant(fileTime.toInstant(), ZoneOffset.systemDefault()), comment)); + } catch (IOException ignored) {} + + return Optional.empty(); + } + + public Path getFile() { return file; } + + public ConfigPOJO.ArchiveFormat getArchiveFormat() { return archiveFormat; } + + public LocalDateTime getCreationTime() { return creationTime; } + + public String getComment() { return comment; } + + @Override + public int compareTo(@NotNull RestoreableFile o) { return creationTime.compareTo(o.creationTime); } + + public String toString() { + return this.getCreationTime().format(Globals.defaultDateTimeFormatter) + (comment != null ? "#" + comment : ""); + } +} diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index c38304d..45b3a15 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -25,11 +25,9 @@ import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.world.World; -import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.config.ConfigHelper; -import net.szum123321.textile_backup.config.ConfigPOJO; import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor; import org.apache.commons.io.file.SimplePathVisitor; import org.jetbrains.annotations.NotNull; @@ -40,13 +38,8 @@ import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; -import java.nio.file.attribute.FileTime; import java.time.*; import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.Optional; - -import static java.nio.file.LinkOption.NOFOLLOW_LINKS; public class Utilities { private final static ConfigHelper config = ConfigHelper.INSTANCE; @@ -72,20 +65,7 @@ public class Utilities { .getSession() .getWorldDirectory(World.OVERWORLD); } - - public static Path getBackupRootPath(String worldName) { - Path path = Path.of(config.get().backupDirectoryPath).toAbsolutePath(); - if (config.get().perWorldBackup) path = path.resolve(worldName); - - try { - Files.createDirectories(path); - } catch (IOException e) { - //I REALLY shouldn't be handling this here - } - - return path; - } public static void deleteDirectory(Path path) throws IOException { Files.walkFileTree(path, new SimplePathVisitor() { @@ -121,6 +101,20 @@ public class Utilities { return System.getProperty("os.name").toLowerCase().contains("win"); } + public static Path getBackupRootPath(String worldName) { + Path path = Path.of(config.get().backupDirectoryPath).toAbsolutePath(); + + if (config.get().perWorldBackup) path = path.resolve(worldName); + + try { + Files.createDirectories(path); + } catch (IOException e) { + //I REALLY shouldn't be handling this here + } + + return path; + } + public static boolean isBlacklisted(Path path) { if(isWindows()) { //hotfix! if (path.getFileName().toString().equals("session.lock")) return true; @@ -129,58 +123,6 @@ public class Utilities { return config.get().fileBlacklist.stream().anyMatch(path::startsWith); } - public static Optional getArchiveExtension(String fileName) { - String[] parts = fileName.split("\\."); - - return Arrays.stream(ConfigPOJO.ArchiveFormat.values()) - .filter(format -> format.getLastPiece().equals(parts[parts.length - 1])) - .findAny(); - } - - public static Optional getArchiveExtension(Path f) { - return getArchiveExtension(f.getFileName().toString()); - } - - public static Optional getFileCreationTime(Path file) { - if(getArchiveExtension(file).isEmpty()) return Optional.empty(); - try { - FileTime fileTime = Files.readAttributes(file, BasicFileAttributes.class, NOFOLLOW_LINKS).creationTime(); - return Optional.of(LocalDateTime.ofInstant(fileTime.toInstant(), ZoneOffset.systemDefault())); - } catch (IOException ignored) {} - - String fileExtension = getArchiveExtension(file).get().getCompleteString(); - - try { - return Optional.of( - LocalDateTime.from( - Utilities.getDateTimeFormatter().parse( - file.getFileName().toString().split(fileExtension)[0].split("#")[0] - ))); - } catch (Exception ignored) {} - - try { - return Optional.of( - LocalDateTime.from( - Globals.defaultDateTimeFormatter.parse( - file.getFileName().toString().split(fileExtension)[0].split("#")[0] - ))); - } catch (Exception ignored) {} - - return Optional.empty(); - } - - public static boolean isValidBackup(Path f) { - return getArchiveExtension(f).isPresent() && getFileCreationTime(f).isPresent() && isFileOk(f); - } - - public static boolean isFileOk(File f) { - return f.exists() && f.isFile(); - } - - public static boolean isFileOk(Path f) { - return Files.exists(f) && Files.isRegularFile(f); - } - public static DateTimeFormatter getDateTimeFormatter() { return DateTimeFormatter.ofPattern(config.get().dateTimeFormat); } diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreContext.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreContext.java index 2e597b3..f5391a5 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreContext.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreContext.java @@ -22,16 +22,17 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; import net.szum123321.textile_backup.core.ActionInitiator; +import net.szum123321.textile_backup.core.RestoreableFile; import javax.annotation.Nullable; -public record RestoreContext(RestoreHelper.RestoreableFile restoreableFile, +public record RestoreContext(RestoreableFile restoreableFile, MinecraftServer server, @Nullable String comment, ActionInitiator initiator, ServerCommandSource commandSource) { public static final class Builder { - private RestoreHelper.RestoreableFile file; + private RestoreableFile file; private MinecraftServer server; private String comment; private ServerCommandSource serverCommandSource; @@ -43,7 +44,7 @@ public record RestoreContext(RestoreHelper.RestoreableFile restoreableFile, return new Builder(); } - public Builder setFile(RestoreHelper.RestoreableFile file) { + public Builder setFile(RestoreableFile file) { this.file = file; return this; } diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java index 085dc6d..5102e52 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java @@ -23,18 +23,14 @@ import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; 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.RestoreableFile; import net.szum123321.textile_backup.core.Utilities; -import org.jetbrains.annotations.NotNull; -import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; public class RestoreHelper { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); @@ -43,16 +39,11 @@ public class RestoreHelper { public static Optional findFileAndLockIfPresent(LocalDateTime backupTime, MinecraftServer server) { Path root = Utilities.getBackupRootPath(Utilities.getLevelName(server)); - Optional optionalFile; - try (Stream stream = Files.list(root)) { - optionalFile = stream - .map(RestoreableFile::newInstance) - .flatMap(Optional::stream) - .filter(rf -> rf.getCreationTime().equals(backupTime)) - .findFirst(); - } catch (IOException e) { - throw new RuntimeException(e); - } + Optional optionalFile = + RestoreableFile.applyOnFiles(root, Optional.empty(), + e -> log.error("An error occurred while trying to lock file!", e), + s -> s.filter(rf -> rf.getCreationTime().equals(backupTime)) + .findFirst()); optionalFile.ifPresent(r -> Globals.INSTANCE.setLockedFile(r.getFile())); @@ -79,66 +70,8 @@ public class RestoreHelper { public static List getAvailableBackups(MinecraftServer server) { Path root = Utilities.getBackupRootPath(Utilities.getLevelName(server)); - try (Stream stream = Files.list(root)) { - return stream.filter(Utilities::isValidBackup) - .map(RestoreableFile::newInstance) - .flatMap(Optional::stream) - .collect(Collectors.toList()); - } catch (IOException e) { - log.error("Error while listing available backups", e); - return new LinkedList<>(); - } - } - - public static class RestoreableFile implements Comparable { - private final Path file; - private final ConfigPOJO.ArchiveFormat archiveFormat; - private final LocalDateTime creationTime; - private final String comment; - - private RestoreableFile(Path file) throws NoSuchElementException { - this.file = file; - archiveFormat = Utilities.getArchiveExtension(file).orElseThrow(() -> new NoSuchElementException("Couldn't get file extension!")); - String extension = archiveFormat.getCompleteString(); - creationTime = Utilities.getFileCreationTime(file).orElseThrow(() -> new NoSuchElementException("Couldn't get file creation time!")); - - final String filename = file.getFileName().toString(); - - if(filename.split("#").length > 1) this.comment = filename.split("#")[1].split(extension)[0]; - else this.comment = null; - } - - public static Optional newInstance(Path file) { - try { - return Optional.of(new RestoreableFile(file)); - } catch (NoSuchElementException ignored) {} - - return Optional.empty(); - } - - public Path getFile() { - return file; - } - - public ConfigPOJO.ArchiveFormat getArchiveFormat() { - return archiveFormat; - } - - public LocalDateTime getCreationTime() { - return creationTime; - } - - public String getComment() { - return comment; - } - - @Override - public int compareTo(@NotNull RestoreHelper.RestoreableFile o) { - return creationTime.compareTo(o.creationTime); - } - - public String toString() { - return this.getCreationTime().format(Globals.defaultDateTimeFormatter) + (comment != null ? "#" + comment : ""); - } + return RestoreableFile.applyOnFiles(root, List.of(), + e -> log.error("Error while listing available backups", e), + s -> s.collect(Collectors.toList())); } } \ No newline at end of file From c22eb7a3b273deed5be7cc9a025e4bd6f0dc77f7 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 30 Aug 2022 14:46:15 +0200 Subject: [PATCH 04/24] made cleanup more readable --- .../textile_backup/core/Cleanup.java | 56 +++++++++---------- .../textile_backup/core/Utilities.java | 1 - 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java index f7f022e..7529d5a 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -30,8 +30,8 @@ import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; import java.time.ZoneOffset; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; +import java.util.Objects; +import java.util.stream.BaseStream; import java.util.stream.Stream; public class Cleanup { @@ -47,11 +47,11 @@ public class Cleanup { if (config.get().maxAge > 0) { // delete files older that configured final long now = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); - deletedFiles += RestoreableFile.applyOnFiles(root, 0, - e -> log.error("An exception occurred while trying to delete old files!", e), + deletedFiles += RestoreableFile.applyOnFiles(root, 0L, + e -> log.error("An exception occurred while trying to delete an old files!", e), stream -> stream.filter(f -> now - f.getCreationTime().toEpochSecond(ZoneOffset.UTC) > config.get().maxAge) - .mapToInt(f -> deleteFile(f.getFile(), ctx)) - .sum() + .filter(f -> deleteFile(f.getFile(), ctx)) + .count() ); } @@ -59,26 +59,26 @@ public class Cleanup { final long maxSize = config.get().maxSize > 0 ? config.get().maxSize * 1024: Long.MAX_VALUE; long[] counts = count(root); + long n = counts[0], size = counts[1]; - AtomicInteger currentNo = new AtomicInteger((int) counts[0]); - AtomicLong currentSize = new AtomicLong(counts[1]); + var it = RestoreableFile.applyOnFiles(root, null, + e -> log.error("An exception occurred while trying to delete old files!", e), BaseStream::iterator); - deletedFiles += RestoreableFile.applyOnFiles(root, 0, - e -> log.error("An exception occurred while trying to delete old files!", e), - stream -> stream.sequential() - .takeWhile(f -> (currentNo.get() > noToKeep) || (currentSize.get() > maxSize)) - .map(RestoreableFile::getFile) - .peek(f -> { - try { - currentSize.addAndGet(-Files.size(f)); - } catch (IOException e) { - currentSize.set(0); - return; - } - currentNo.decrementAndGet(); - }) - .mapToInt(f -> deleteFile(f, ctx)) - .sum()); + if(Objects.isNull(it)) return deletedFiles; + + while(it.hasNext() && (n > noToKeep || size > maxSize)) { + Path f = it.next().getFile(); + long x; + try { + x = Files.size(f); + } catch (IOException e) { size = 0; continue; } + + if(!deleteFile(f, ctx)) continue; + + size -= x; + n--; + deletedFiles++; + } return deletedFiles; } @@ -111,16 +111,16 @@ public class Cleanup { } //1 -> ok, 0 -> err - private static int deleteFile(Path f, ServerCommandSource ctx) { - if(Globals.INSTANCE.getLockedFile().filter(p -> p == f).isPresent()) return 0; + private static boolean deleteFile(Path f, ServerCommandSource ctx) { + if(Globals.INSTANCE.getLockedFile().filter(p -> p == f).isPresent()) return false; try { Files.delete(f); log.sendInfoAL(ctx, "Deleted: {}", f); } catch (IOException e) { if(Utilities.wasSentByPlayer(ctx)) log.sendError(ctx, "Something went wrong while deleting: {}.", f); log.error("Something went wrong while deleting: {}.", f, e); - return 0; + return false; } - return 1; + return true; } } \ No newline at end of file diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index 45b3a15..de88a1b 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -32,7 +32,6 @@ import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor; import org.apache.commons.io.file.SimplePathVisitor; import org.jetbrains.annotations.NotNull; -import java.io.File; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; From c7fd6d3f8eb692fd9999da871806e0dd1ff6fff0 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Wed, 31 Aug 2022 22:32:56 +0200 Subject: [PATCH 05/24] Did I forget the sort? --- .../java/net/szum123321/textile_backup/core/Cleanup.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java index 7529d5a..7c90c74 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -31,7 +31,6 @@ import java.nio.file.Path; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.Objects; -import java.util.stream.BaseStream; import java.util.stream.Stream; public class Cleanup { @@ -61,8 +60,9 @@ public class Cleanup { long[] counts = count(root); long n = counts[0], size = counts[1]; - var it = RestoreableFile.applyOnFiles(root, null, - e -> log.error("An exception occurred while trying to delete old files!", e), BaseStream::iterator); + var it = RestoreableFile.applyOnFiles(root, null, + e -> log.error("An exception occurred while trying to delete old files!", e), + s -> s.sorted().iterator()); if(Objects.isNull(it)) return deletedFiles; From 8cede1756834ac479499d65eb18baea4ad9371f9 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Wed, 31 Aug 2022 22:36:50 +0200 Subject: [PATCH 06/24] because of that return, the finally block would never run --- .../core/create/MakeBackupRunnable.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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 05e8c3a..8bfa995 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 @@ -67,17 +67,8 @@ public class MakeBackupRunnable implements Runnable { log.trace("Outfile is: {}", outFile); - try { - Files.createDirectories(outFile.getParent()); - Files.createFile(outFile); - } catch (IOException e) { - log.error("An exception occurred when trying to create new backup file!", e); - - if(context.initiator() == ActionInitiator.Player) - log.sendError(context, "An exception occurred when trying to create new backup file!"); - - return; - } + Files.createDirectories(outFile.getParent()); + Files.createFile(outFile); int coreCount; @@ -119,6 +110,11 @@ public class MakeBackupRunnable implements Runnable { } else { log.sendInfoAL(context, "Done!"); } + } catch (IOException e) { + log.error("An exception occurred when trying to create new backup file!", e); + + if(context.initiator() == ActionInitiator.Player) + log.sendError(context, "An exception occurred when trying to create new backup file!"); } finally { Utilities.enableWorldSaving(context.server()); Globals.INSTANCE.disableWatchdog = false; From 91447b7b3c3a367c9c42ce5da5f77baccf304ba3 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Wed, 31 Aug 2022 22:42:39 +0200 Subject: [PATCH 07/24] This shouldn't be here... --- .../core/create/compressors/AbstractCompressor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java index 5938097..744a89e 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java @@ -73,7 +73,6 @@ public abstract class AbstractCompressor { } } catch (IOException | InterruptedException | ExecutionException e) { log.error("An exception occurred!", e); - } catch (Exception e) { if(ctx.initiator() == ActionInitiator.Player) log.sendError(ctx, "Something went wrong while compressing files!"); } finally { From 6707e813b29ac0342cb999f91ed6b4c32b340574 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Wed, 31 Aug 2022 22:50:48 +0200 Subject: [PATCH 08/24] explicit presence declaration --- .../commands/FileSuggestionProvider.java | 12 +++++------- .../textile_backup/core/RestoreableFile.java | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java index d7fcea5..120e5a7 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java +++ b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java @@ -34,9 +34,7 @@ import java.util.concurrent.CompletableFuture; public final class FileSuggestionProvider implements SuggestionProvider { private static final FileSuggestionProvider INSTANCE = new FileSuggestionProvider(); - public static FileSuggestionProvider Instance() { - return INSTANCE; - } + public static FileSuggestionProvider Instance() { return INSTANCE; } @Override public CompletableFuture getSuggestions(CommandContext ctx, SuggestionsBuilder builder) { @@ -47,14 +45,14 @@ public final class FileSuggestionProvider implements SuggestionProvider { public LocalDateTime getCreationTime() { return creationTime; } - public String getComment() { return comment; } + public Optional getComment() { return Optional.ofNullable(comment); } @Override public int compareTo(@NotNull RestoreableFile o) { return creationTime.compareTo(o.creationTime); } From 81c5cd04cb0e036d079cb945e53fae0fa623ef7b Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Wed, 31 Aug 2022 22:53:30 +0200 Subject: [PATCH 09/24] Commented some more code. BackupScheduler is now static --- .../szum123321/textile_backup/Globals.java | 5 +--- .../textile_backup/TextileBackup.java | 3 +- .../textile_backup/core/ActionInitiator.java | 7 +++-- .../textile_backup/core/Cleanup.java | 5 +++- .../textile_backup/core/RestoreableFile.java | 4 +++ .../textile_backup/core/Utilities.java | 1 - .../core/create/BackupContext.java | 6 +--- .../core/create/BackupScheduler.java | 28 +++++++++++++------ .../core/create/MakeBackupRunnable.java | 5 +++- .../compressors/AbstractCompressor.java | 5 +++- .../core/restore/RestoreBackupRunnable.java | 1 + .../mixin/DedicatedServerWatchdogMixin.java | 4 +++ 12 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/Globals.java b/src/main/java/net/szum123321/textile_backup/Globals.java index 7172c2d..cf642fb 100644 --- a/src/main/java/net/szum123321/textile_backup/Globals.java +++ b/src/main/java/net/szum123321/textile_backup/Globals.java @@ -36,16 +36,13 @@ import java.util.concurrent.atomic.AtomicBoolean; public class Globals { public static final Globals INSTANCE = new Globals(); - public final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss"); - 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(); public final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true); - public boolean disableWatchdog = false; private boolean disableTMPFiles = false; - private AwaitThread restoreAwaitThread = null; private Path lockedPath = null; diff --git a/src/main/java/net/szum123321/textile_backup/TextileBackup.java b/src/main/java/net/szum123321/textile_backup/TextileBackup.java index 81d514a..d1e313b 100644 --- a/src/main/java/net/szum123321/textile_backup/TextileBackup.java +++ b/src/main/java/net/szum123321/textile_backup/TextileBackup.java @@ -55,7 +55,7 @@ public class TextileBackup implements ModInitializer { ConfigHelper.updateInstance(AutoConfig.register(ConfigPOJO.class, JanksonConfigSerializer::new)); - ServerTickEvents.END_SERVER_TICK.register(new BackupScheduler()::tick); + ServerTickEvents.END_SERVER_TICK.register(BackupScheduler::tick); //Restart Executor Service in single-player ServerLifecycleEvents.SERVER_STARTING.register(server -> { @@ -63,6 +63,7 @@ public class TextileBackup implements ModInitializer { Globals.INSTANCE.updateTMPFSFlag(server); }); + //Wait 60s for already submited backups to finish. After that kill the bastards and run the one last if required ServerLifecycleEvents.SERVER_STOPPED.register(server -> { Globals.INSTANCE.shutdownQueueExecutor(60000); diff --git a/src/main/java/net/szum123321/textile_backup/core/ActionInitiator.java b/src/main/java/net/szum123321/textile_backup/core/ActionInitiator.java index f965874..07375b9 100644 --- a/src/main/java/net/szum123321/textile_backup/core/ActionInitiator.java +++ b/src/main/java/net/szum123321/textile_backup/core/ActionInitiator.java @@ -18,10 +18,13 @@ package net.szum123321.textile_backup.core; +/** + * Enum representing possible sources of action + */ public enum ActionInitiator { Player("Player", "by"), - ServerConsole("Server Console", "from"), - Timer("Timer", "by"), + ServerConsole("Server Console", "from"), //some/ting typed a command and it was not a player (command blocks and server console count) + Timer("Timer", "by"), //a.k.a scheduler Shutdown("Server Shutdown", "by"), Restore("Backup Restoration", "because of"), Null("Null (That shouldn't have happened)", "form"); diff --git a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java index 7c90c74..77076e8 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -33,6 +33,9 @@ import java.time.ZoneOffset; import java.util.Objects; import java.util.stream.Stream; +/** + * Set of utility used for removing old backups + */ public class Cleanup { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); private final static ConfigHelper config = ConfigHelper.INSTANCE; @@ -55,7 +58,7 @@ public class Cleanup { } final int noToKeep = config.get().backupsToKeep > 0 ? config.get().backupsToKeep : Integer.MAX_VALUE; - final long maxSize = config.get().maxSize > 0 ? config.get().maxSize * 1024: Long.MAX_VALUE; + final long maxSize = config.get().maxSize > 0 ? config.get().maxSize * 1024: Long.MAX_VALUE; //max number of bytes to keep long[] counts = count(root); long n = counts[0], size = counts[1]; diff --git a/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java index 8684045..e9f41b4 100644 --- a/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java +++ b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java @@ -40,6 +40,9 @@ import java.util.stream.Stream; import static java.nio.file.LinkOption.NOFOLLOW_LINKS; +/** + * This class parses backup files, extracting its creation time, format and possibly comment + */ public class RestoreableFile implements Comparable { private final Path file; private final ConfigPOJO.ArchiveFormat archiveFormat; @@ -53,6 +56,7 @@ public class RestoreableFile implements Comparable { this.comment = comment; } + //removes repetition of the files stream thingy with awfully large lambdas public static T applyOnFiles(Path root, T def, Consumer errorConsumer, Function, T> streamConsumer) { try (Stream stream = Files.list(root)) { return streamConsumer.apply(stream.flatMap(f -> RestoreableFile.build(f).stream())); diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index de88a1b..5482708 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -65,7 +65,6 @@ public class Utilities { .getWorldDirectory(World.OVERWORLD); } - public static void deleteDirectory(Path path) throws IOException { Files.walkFileTree(path, new SimplePathVisitor() { @Override diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupContext.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupContext.java index ad93166..63a3e3e 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupContext.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupContext.java @@ -21,12 +21,9 @@ package net.szum123321.textile_backup.core.create; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.util.Util; import net.szum123321.textile_backup.core.ActionInitiator; import org.jetbrains.annotations.NotNull; -import java.util.UUID; - public record BackupContext(@NotNull MinecraftServer server, ServerCommandSource commandSource, ActionInitiator initiator, @@ -103,8 +100,7 @@ public record BackupContext(@NotNull MinecraftServer server, if (server == null) { if (commandSource != null) setServer(commandSource.getServer()); - else - throw new RuntimeException("Neither MinecraftServer or ServerCommandSource were provided!"); + else throw new RuntimeException("Neither MinecraftServer or ServerCommandSource were provided!"); } return new BackupContext(server, commandSource, initiator, save, comment); diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java index 6ce816a..c4d7e1b 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java @@ -25,24 +25,32 @@ import net.szum123321.textile_backup.core.ActionInitiator; import java.time.Instant; +/** + * Runs backup on a preset interval + *
+ * The important thing to note:
+ * In the case that doBackupsOnEmptyServer == false and there have been made backups with players online, + * then everyone left the backup that was scheduled with player is still going to run. So it might appear as though there + * has been made backup with no players online despite the config. This is the expected behaviour + *
+ * Furthermore, it uses system time + */ public class BackupScheduler { private final static ConfigHelper config = ConfigHelper.INSTANCE; - private boolean scheduled; - private long nextBackup; + //Scheduled flag tells whether we have decided to run another backup + private static boolean scheduled = false; + private static long nextBackup = - 1; - public BackupScheduler() { - scheduled = false; - nextBackup = -1; - } - - public void tick(MinecraftServer server) { + public static void tick(MinecraftServer server) { if(config.get().backupInterval < 1) return; long now = Instant.now().getEpochSecond(); if(config.get().doBackupsOnEmptyServer || server.getPlayerManager().getCurrentPlayerCount() > 0) { + //Either just run backup with no one playing or there's at least one player if(scheduled) { if(nextBackup <= now) { + //It's time to run Globals.INSTANCE.getQueueExecutor().submit( MakeBackupRunnableFactory.create( BackupContext.Builder @@ -57,11 +65,15 @@ public class BackupScheduler { nextBackup = now + config.get().backupInterval; } } else { + //Either server just started or a new player joined after the last backup has finished + //So let's schedule one some time from now nextBackup = now + config.get().backupInterval; scheduled = true; } } else if(!config.get().doBackupsOnEmptyServer && server.getPlayerManager().getCurrentPlayerCount() == 0) { + //Do the final backup. No one's on-line and doBackupsOnEmptyServer == false if(scheduled && nextBackup <= now) { + //Verify we hadn't done the final one and its time to do so Globals.INSTANCE.getQueueExecutor().submit( MakeBackupRunnableFactory.create( BackupContext.Builder 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 8bfa995..7b6adee 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 @@ -37,6 +37,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; +/** + * The actual object responsible for creating the backup + */ public class MakeBackupRunnable implements Runnable { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); private final static ConfigHelper config = ConfigHelper.INSTANCE; @@ -87,7 +90,7 @@ public class MakeBackupRunnable implements Runnable { log.trace("Using PARALLEL Zip Compressor. Threads: {}", coreCount); } else { ZipCompressor.getInstance().createArchive(world, outFile, context, coreCount); - log.trace("Using REGULAR Zip Compressor. Threads: {}"); + log.trace("Using REGULAR Zip Compressor."); } } case BZIP2 -> ParallelBZip2Compressor.getInstance().createArchive(world, outFile, context, coreCount); diff --git a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java index 744a89e..45e5f65 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java @@ -33,6 +33,9 @@ import java.time.Instant; import java.util.concurrent.ExecutionException; import java.util.stream.Stream; +/** + * Basic abstract class representing directory compressor + */ public abstract class AbstractCompressor { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); @@ -88,7 +91,7 @@ public abstract class AbstractCompressor { protected abstract void addEntry(Path file, String entryName, OutputStream arc) throws IOException; protected void finish(OutputStream arc) throws InterruptedException, ExecutionException, IOException { - //Basically this function is only needed for the ParallelZipCompressor to write out ParallelScatterZipCreator + //This function is only needed for the ParallelZipCompressor to write out ParallelScatterZipCreator } protected void close() { diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java index 2f3e207..be798b4 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +//TODO: Verify backup's validity? public class RestoreBackupRunnable implements Runnable { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); private final static ConfigHelper config = ConfigHelper.INSTANCE; diff --git a/src/main/java/net/szum123321/textile_backup/mixin/DedicatedServerWatchdogMixin.java b/src/main/java/net/szum123321/textile_backup/mixin/DedicatedServerWatchdogMixin.java index 2b9f0bb..415939c 100644 --- a/src/main/java/net/szum123321/textile_backup/mixin/DedicatedServerWatchdogMixin.java +++ b/src/main/java/net/szum123321/textile_backup/mixin/DedicatedServerWatchdogMixin.java @@ -25,6 +25,10 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; +/** + * This mixin should numb Watchdog while a backup runs. + * If works as intended solves issues with watchdog errors + */ @Mixin(DedicatedServerWatchdog.class) public class DedicatedServerWatchdogMixin { From b908e651a184350f07bfef9f83fa1826a7bd0f27 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Wed, 31 Aug 2022 23:00:24 +0200 Subject: [PATCH 10/24] Forgot to commit --- .../java/net/szum123321/textile_backup/config/ConfigPOJO.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java b/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java index c271df6..d6ad376 100644 --- a/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java +++ b/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java @@ -18,6 +18,7 @@ package net.szum123321.textile_backup.config; +import blue.endless.jankson.annotation.SerializedName; import me.shedaniel.autoconfig.ConfigData; import me.shedaniel.autoconfig.annotation.Config; import me.shedaniel.autoconfig.annotation.ConfigEntry; @@ -63,8 +64,9 @@ public class ConfigPOJO implements ConfigData { public boolean backupOldWorlds = true; @Comment("\nA path to the backup folder\n") + @SerializedName("path") @ConfigEntry.Gui.NoTooltip() - public String path = "backup/"; + public String backupDirectoryPath = "backup/"; @Comment(""" \nThis setting allows you to exclude files form being backed-up. From 2bde644c76d952a035a355b806dfa5a5dd18e7f0 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Wed, 31 Aug 2022 23:00:48 +0200 Subject: [PATCH 11/24] loom update --- build.gradle | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 583a3aa..503fdf3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' + id 'fabric-loom' version '1.0-SNAPSHOT' id 'maven-publish' } @@ -13,12 +13,7 @@ group = project.maven_group repositories{ maven { url 'https://jitpack.io' } maven { url "https://maven.shedaniel.me/" } - maven { - url "https://maven.terraformersmc.com/releases/" - content { - includeGroup "com.terraformersmc" - } - } + maven { url "https://maven.terraformersmc.com/releases/" } mavenCentral() } From 8b7dbdc8e82eb567ceec82b4a6651950325db3d7 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Fri, 2 Sep 2022 21:05:27 +0200 Subject: [PATCH 12/24] added better catch and changed default executorService to null --- .../java/net/szum123321/textile_backup/Globals.java | 5 +++-- .../textile_backup/core/create/MakeBackupRunnable.java | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) 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) From dc24d51674ed54c4fe3823fd1b137898deb32648 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sun, 4 Sep 2022 10:49:08 +0200 Subject: [PATCH 13/24] stream is closed --- src/main/java/net/szum123321/textile_backup/core/Cleanup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java index 77076e8..83cc3eb 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -65,7 +65,7 @@ public class Cleanup { var it = RestoreableFile.applyOnFiles(root, null, e -> log.error("An exception occurred while trying to delete old files!", e), - s -> s.sorted().iterator()); + s -> s.sorted().toList().iterator()); if(Objects.isNull(it)) return deletedFiles; From 4cbe18f318a34086a225d56f4979732530dfb642 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sun, 4 Sep 2022 10:49:49 +0200 Subject: [PATCH 14/24] removed deprecated code --- .../java/org/at4j/comp/bzip2/BZip2OutputStream.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/main/java/org/at4j/comp/bzip2/BZip2OutputStream.java b/src/main/java/org/at4j/comp/bzip2/BZip2OutputStream.java index 5d6c7d6..d5f2d61 100644 --- a/src/main/java/org/at4j/comp/bzip2/BZip2OutputStream.java +++ b/src/main/java/org/at4j/comp/bzip2/BZip2OutputStream.java @@ -37,7 +37,7 @@ import org.at4j.support.io.LittleEndianBitOutputStream; * @since 1.1 * @see BZip2OutputStreamSettings */ -public class BZip2OutputStream extends OutputStream +public class BZip2OutputStream extends OutputStream implements AutoCloseable { private static final byte[] EOS_MAGIC = new byte[] { 0x17, 0x72, 0x45, 0x38, 0x50, (byte) 0x90 }; @@ -263,17 +263,6 @@ public class BZip2OutputStream extends OutputStream return this == o; } - /** - * Close the stream if the client has been sloppy about it. - */ - @Override - protected void finalize() throws Throwable - { - close(); - super.finalize(); - } - - /** * Create a {@link BZip2EncoderExecutorService} that can be shared between * several {@link BZip2OutputStream}:s to spread the bzip2 encoding work From 13a114baa6f26eb1316ce06db76b95422164ff58 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sun, 4 Sep 2022 10:55:06 +0200 Subject: [PATCH 15/24] gradlew update --- build.gradle | 4 +- gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 59821 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 270 +++++++++++++---------- gradlew.bat | 25 +-- 5 files changed, 168 insertions(+), 133 deletions(-) diff --git a/build.gradle b/build.gradle index 503fdf3..fc24c66 100644 --- a/build.gradle +++ b/build.gradle @@ -39,11 +39,11 @@ dependencies { include "org.apache.commons:commons-compress:1.21" //LZMA support - modImplementation 'org.tukaani:xz:1.9' + implementation 'org.tukaani:xz:1.9' include "org.tukaani:xz:1.9" //Gzip compression, parallel, GITHUB - modImplementation "com.github.shevek:parallelgzip:${project.pgzip_commit_hash}" + implementation "com.github.shevek:parallelgzip:${project.pgzip_commit_hash}" include "com.github.shevek:parallelgzip:${project.pgzip_commit_hash}" // Lazy DFU makes the dev env start up much faster by loading DataFixerUpper lazily, which would otherwise take a long time. We rarely need it anyway. diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c023ec8b20f512888fe07c5bd3ff77bb8f..41d9927a4d4fb3f96a785543079b8df6723c946b 100644 GIT binary patch delta 20926 zcmY(p19zBh*tDC*wr$(CZQHhW$3|n@W@Fn%V>fmhHTa(WuDw3|hwGe~>zEmy1FKsG zYYc=z@M+Z>Uk4n- zf>LPE!P?mA5#!>@QlN|1%u#eAY%z9sYzTix2)?dl^qr+FV;S+1iF%X=EN6X@efcip zx4L{6MHen@KT&~3ddxw!vGK3 zDR6IzmfS(C#hBd@wn!OgvMoF}phsEk&F5-Dcwt7G2xG&Dm&xutI)E-Va!-qKz~+w0 z-=AFd+H(~(Q$3%N5nez;ZIxbBM31j>5Nyo-YkiExY1M<@u<0e*nz!!R z;{N$-qP&QO{9nWv^INxb>J`g-yYMA$eDo8qb{Bw9^fZ9m+S(Rz2Zph#(1yUfaZB?I z#eOI?a)(CpDeqla5F^C|B-C7T7CC2S%N!%mR&iZ=7m$e>8JAYv-&Am?exYu9F)s@^ z9C)0W-|mW~Vu~>&H5kvxytGG67Zv0pEg}b-m(ggB8~^+aXZ&XbbIGOp!bkEM{Np3q z@-SX2K#W$Hez?IRlyxVVm5t}P- zltiFvZ&=0@Q}LqUpz=6(h07TA`ZYSz8rFm{Z{-~Qw!}yL8*=dtF@T_H90~mu8Kw1t z)le9013)H|!YcV=K?2_d9ifA*Q*M@vBRhpdibeK-gIY}{cl&GETL*)(oq?%BoP{H$ zn4O~f$L0bBm?qk}Rxw_2yYt*IM#^$v;IJSd(9j_NsR~GbNZnQu7zjwxm0I8$)sVjq#M(yl^fk=Y`b_$ZVpEG;yCH|Z~I1>MTYdpi8P>+NQC zE_BSsn_WD^EqD%(G{YUlEBLDQx{o%zvDKPVnupGJe#6t<@AjO#$J70?_*f7K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=e#vvR4Seglugurm_{K7C!+zgAhc*4W`IEwO54A`U?RgL^+npZCRKhsH zTe3Xs+vb2WRfkgKmLo=AW1>;y!EC$=j)XO4V;r3ik9nj&d8A1j&VeTyBj_Q~?bnp9 z+0au=+KQ#8Pqvrc8{b`RR27HU`5_o85Z+V^hwJyscoFJ>BR#b|k^$_CQbovY`R11> z1m{y9AJ_FSebqAlB{7GL4twf|U8Z6envXF?iI{2AI(it$7#b01X&}tS5MA`rM zowK)qw0lJHWL6bOcKu7F0Ila_fDJz|V@?;)@(0)E41rXCP-$KcX!i%hgRg)C3v}Rz zc^IG@L{Qnl{dpY#@*6mq3I`{`SbyaL#w@^qGz`(?89_^MKmz+%qS_xxO+>86&{6-L zWKlROiqOde`hJ!G1RfE^?$4?~Pb^U^OJMjl8lb@<40s<;H036FODHZ~?mK1@#e1dqL7-fvm zbFLWt@LU!YT}A>VB}7ofvNUk=f+#L7D*_uYiP3sr(-VTzfzB&1K(T^o;;P~xnuKcp zolHn2p%Vcz;l+XBb}+e15cI$!frVazhyYs#{yQM!co;x70Pf+PfQdoSVpSd#nScuZ w|E&DqkiEp6nWHb}B;da$<=?F+{O4J~(cC2_GD0yC1R_ni)(HQ!%J47kKb!F!p8x;= diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a2..41dfb87 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 8e25e6c..1b6c787 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,113 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,84 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done fi +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9618d8d..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell From dc974aa35ba50f449258eedb39cd2e6d0bc1ad0a Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 4 Oct 2022 18:56:08 +0200 Subject: [PATCH 16/24] improved comment quality --- .../net/szum123321/textile_backup/core/Cleanup.java | 2 +- .../textile_backup/core/create/BackupScheduler.java | 13 +++++++------ .../textile_backup/core/restore/RestoreHelper.java | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java index 83cc3eb..bb80c89 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -50,7 +50,7 @@ public class Cleanup { final long now = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); deletedFiles += RestoreableFile.applyOnFiles(root, 0L, - e -> log.error("An exception occurred while trying to delete an old files!", e), + e -> log.error("An exception occurred while trying to delete old files!", e), stream -> stream.filter(f -> now - f.getCreationTime().toEpochSecond(ZoneOffset.UTC) > config.get().maxAge) .filter(f -> deleteFile(f.getFile(), ctx)) .count() diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java index c4d7e1b..82d8bbe 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java @@ -27,12 +27,13 @@ import java.time.Instant; /** * Runs backup on a preset interval - *
+ *

* The important thing to note:
- * In the case that doBackupsOnEmptyServer == false and there have been made backups with players online, - * then everyone left the backup that was scheduled with player is still going to run. So it might appear as though there - * has been made backup with no players online despite the config. This is the expected behaviour - *
+ * The decision of whether to do a backup or not is made at the time of scheduling, that is, whenever the nextBackup + * flag is set. This means that even if doBackupsOnEmptyServer=false, the backup that was scheduled with players online will + * still go thorough.
+ * It might appear as though there has been made a backup with no players online despite the config. This is the expected behaviour + *

* Furthermore, it uses system time */ public class BackupScheduler { @@ -73,7 +74,7 @@ public class BackupScheduler { } else if(!config.get().doBackupsOnEmptyServer && server.getPlayerManager().getCurrentPlayerCount() == 0) { //Do the final backup. No one's on-line and doBackupsOnEmptyServer == false if(scheduled && nextBackup <= now) { - //Verify we hadn't done the final one and its time to do so + //Verify we hadn't done the final one, and it's time to do so Globals.INSTANCE.getQueueExecutor().submit( MakeBackupRunnableFactory.create( BackupContext.Builder diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java index 5102e52..de1fa44 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java @@ -41,7 +41,7 @@ public class RestoreHelper { Optional optionalFile = RestoreableFile.applyOnFiles(root, Optional.empty(), - e -> log.error("An error occurred while trying to lock file!", e), + e -> log.error("An exception occurred while trying to lock the file!", e), s -> s.filter(rf -> rf.getCreationTime().equals(backupTime)) .findFirst()); From 53a563937380913b358e545c42293e3ffd3546b2 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 4 Oct 2022 18:56:48 +0200 Subject: [PATCH 17/24] repaired bad error handling --- .../textile_backup/commands/manage/DeleteCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java b/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java index 6fb3ba0..5fc0279 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java @@ -61,12 +61,9 @@ public class DeleteCommand { Path root = Utilities.getBackupRootPath(Utilities.getLevelName(source.getServer())); RestoreableFile.applyOnFiles(root, Optional.empty(), - e -> { - log.sendError(source, "Couldn't find file by this name."); - log.sendHint(source, "Maybe try /backup list"); - }, + e -> log.sendErrorAL(source, "An exception occurred while trying to delete a file!", e), stream -> stream.filter(f -> f.getCreationTime().equals(dateTime)).map(RestoreableFile::getFile).findFirst() - ).ifPresent(file -> { + ).ifPresentOrElse(file -> { if(Globals.INSTANCE.getLockedFile().filter(p -> p == file).isEmpty()) { try { Files.delete((Path) file); @@ -81,6 +78,9 @@ public class DeleteCommand { log.sendError(source, "Couldn't delete the file because it's being restored right now."); log.sendHint(source, "If you want to abort restoration then use: /backup killR"); } + }, () -> { + log.sendInfo(source, "Couldn't find file by this name."); + log.sendInfo(source, "Maybe try /backup list"); } ); return 0; From fe25b1eec5d5d017a9080df874be5d89eca176cf Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sat, 5 Nov 2022 13:30:45 +0100 Subject: [PATCH 18/24] typos --- src/main/java/net/szum123321/textile_backup/core/Cleanup.java | 2 +- .../textile_backup/core/create/BackupScheduler.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java index bb80c89..0894ce4 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -34,7 +34,7 @@ import java.util.Objects; import java.util.stream.Stream; /** - * Set of utility used for removing old backups + * Utility used for removing old backups */ public class Cleanup { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java index 82d8bbe..fb54d37 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupScheduler.java @@ -31,7 +31,7 @@ import java.time.Instant; * The important thing to note:
* The decision of whether to do a backup or not is made at the time of scheduling, that is, whenever the nextBackup * flag is set. This means that even if doBackupsOnEmptyServer=false, the backup that was scheduled with players online will - * still go thorough.
+ * still go through.
* It might appear as though there has been made a backup with no players online despite the config. This is the expected behaviour *

* Furthermore, it uses system time @@ -90,4 +90,4 @@ public class BackupScheduler { } } } -} \ No newline at end of file +} From 3f2658ed9683bbd2cbdb89df25d04e2acac4bb30 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sat, 5 Nov 2022 13:31:44 +0100 Subject: [PATCH 19/24] Cleanup is now implements Callable --- .../commands/create/CleanupCommand.java | 2 +- .../textile_backup/core/Cleanup.java | 19 ++++++++++++++----- .../core/create/MakeBackupRunnable.java | 2 +- .../core/restore/RestoreBackupRunnable.java | 1 - 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/commands/create/CleanupCommand.java b/src/main/java/net/szum123321/textile_backup/commands/create/CleanupCommand.java index 05dafce..c0567ee 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/create/CleanupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/create/CleanupCommand.java @@ -38,7 +38,7 @@ public class CleanupCommand { log.sendInfo( source, "Deleted: {} files.", - Cleanup.executeFileLimit(source, Utilities.getLevelName(source.getServer())) + new Cleanup(source, Utilities.getLevelName(source.getServer())).call() ); return 1; diff --git a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java index 0894ce4..56fd97d 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Cleanup.java +++ b/src/main/java/net/szum123321/textile_backup/core/Cleanup.java @@ -31,16 +31,25 @@ import java.nio.file.Path; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.Objects; +import java.util.concurrent.Callable; import java.util.stream.Stream; /** * Utility used for removing old backups */ -public class Cleanup { +public class Cleanup implements Callable { private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); private final static ConfigHelper config = ConfigHelper.INSTANCE; - public static int executeFileLimit(ServerCommandSource ctx, String worldName) { + private final ServerCommandSource ctx; + private final String worldName; + + public Cleanup(ServerCommandSource ctx, String worldName) { + this.ctx = ctx; + this.worldName = worldName; + } + + public Integer call() { Path root = Utilities.getBackupRootPath(worldName); int deletedFiles = 0; @@ -86,7 +95,7 @@ public class Cleanup { return deletedFiles; } - private static long[] count(Path root) { + private long[] count(Path root) { long n = 0, size = 0; try(Stream stream = Files.list(root)) { @@ -108,13 +117,13 @@ public class Cleanup { return new long[]{n, size}; } - private static boolean isEmpty(Path root) { + private boolean isEmpty(Path root) { if (!Files.isDirectory(root)) return false; return RestoreableFile.applyOnFiles(root, false, e -> {}, s -> s.findFirst().isEmpty()); } //1 -> ok, 0 -> err - private static boolean deleteFile(Path f, ServerCommandSource ctx) { + private boolean deleteFile(Path f, ServerCommandSource ctx) { if(Globals.INSTANCE.getLockedFile().filter(p -> p == f).isPresent()) return false; try { Files.delete(f); 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 e184aab..13bda1b 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 @@ -104,7 +104,7 @@ public class MakeBackupRunnable implements Runnable { case TAR -> new AbstractTarArchiver().createArchive(world, outFile, context, coreCount); } - Cleanup.executeFileLimit(context.commandSource(), Utilities.getLevelName(context.server())); + new Cleanup(context.commandSource(), Utilities.getLevelName(context.server())).call(); if(config.get().broadcastBackupDone) { Utilities.notifyPlayers( diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java index be798b4..f2dd22d 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java @@ -83,7 +83,6 @@ public class RestoreBackupRunnable implements Runnable { log.info("Deleting old world..."); Utilities.deleteDirectory(worldFile); - Files.move(tmp, worldFile); if (config.get().deleteOldBackupAfterRestore) { From 14e82639a8d90e61b45361a39f3607280d2fa6dd Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sat, 5 Nov 2022 13:33:49 +0100 Subject: [PATCH 20/24] further dev environment shenanigans --- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index fc24c66..6d92a9e 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ archivesBaseName = project.archives_base_name version = "${project.mod_version}-${getMcMinor(project.minecraft_version)}" group = project.maven_group -repositories{ +repositories { maven { url 'https://jitpack.io' } maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.terraformersmc.com/releases/" } @@ -35,7 +35,7 @@ dependencies { modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") //General compression library - modImplementation "org.apache.commons:commons-compress:1.21" + implementation "org.apache.commons:commons-compress:1.21" include "org.apache.commons:commons-compress:1.21" //LZMA support diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb87..ae04661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 5b60df3..b02216b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,10 @@ pluginManagement { repositories { - jcenter() maven { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + mavenCentral() gradlePluginPortal() } } From 015184a2329a59d338bbbb23aa332ecae88f2522 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sun, 6 Nov 2022 10:56:27 +0100 Subject: [PATCH 21/24] added dev notes --- DEV_NOTES | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 DEV_NOTES diff --git a/DEV_NOTES b/DEV_NOTES new file mode 100644 index 0000000..ee4c550 --- /dev/null +++ b/DEV_NOTES @@ -0,0 +1,3 @@ +NoClassDefFoundError in dev: + - Intellij appears to add Common Compress into the excluded path in dev environment. + To repair this go to Edit Configuration, select either server or client and remove common compress from Modify Classpath \ No newline at end of file From 2f11548fef46e234c8bd384396807345e3e7183d Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sun, 6 Nov 2022 10:59:03 +0100 Subject: [PATCH 22/24] bugfix + typos --- .../commands/FileSuggestionProvider.java | 4 +++- .../textile_backup/core/RestoreableFile.java | 4 ++-- .../szum123321/textile_backup/core/Utilities.java | 15 ++++++++------- .../core/create/MakeBackupRunnable.java | 2 +- .../core/restore/RestoreBackupRunnable.java | 1 + .../assets/textile_backup/lang/en_us.json | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java index 120e5a7..e4ef038 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java +++ b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java @@ -40,7 +40,9 @@ public final class FileSuggestionProvider implements SuggestionProvider getSuggestions(CommandContext ctx, SuggestionsBuilder builder) { String remaining = builder.getRemaining(); - for (RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getServer())) { + var files = RestoreHelper.getAvailableBackups(ctx.getSource().getServer()); + + for (RestoreableFile file: files) { String formattedCreationTime = file.getCreationTime().format(Globals.defaultDateTimeFormatter); if (formattedCreationTime.startsWith(remaining)) { diff --git a/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java index e9f41b4..b44d9e5 100644 --- a/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java +++ b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java @@ -83,8 +83,8 @@ public class RestoreableFile implements Comparable { String comment = null; if(filename.contains("#")) { - comment = filename.substring(filename.indexOf("#"), parsed_pos); - parsed_pos -= comment.length() - 1; + comment = filename.substring(filename.indexOf("#") + 1, parsed_pos); + parsed_pos -= comment.length() + 1; } var time_string = filename.substring(0, parsed_pos); diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index 5482708..65a6f9f 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -44,9 +44,8 @@ public class Utilities { private final static ConfigHelper config = ConfigHelper.INSTANCE; private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); - public static boolean wasSentByPlayer(ServerCommandSource source) { - return source.isExecutedByPlayer(); - } + //I'm keeping this wrapper function for easier backporting + public static boolean wasSentByPlayer(ServerCommandSource source) { return source.isExecutedByPlayer(); } public static void notifyPlayers(@NotNull MinecraftServer server, String msg) { MutableText message = log.getPrefixText(); @@ -104,10 +103,12 @@ public class Utilities { if (config.get().perWorldBackup) path = path.resolve(worldName); - try { - Files.createDirectories(path); - } catch (IOException e) { - //I REALLY shouldn't be handling this here + if(Files.notExists(path)) { + try { + Files.createDirectories(path); + } catch (IOException e) { + //I REALLY shouldn't be handling this here + } } return path; 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 13bda1b..f2184b9 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 @@ -115,7 +115,7 @@ public class MakeBackupRunnable implements Runnable { log.sendInfoAL(context, "Done!"); } } catch (Throwable e) { - //ExecutorService swallows exception, so I need to catch everythin + //ExecutorService swallows exception, so I need to catch everything log.error("An exception occurred when trying to create new backup file!", e); if(context.initiator() == ActionInitiator.Player) diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java index f2dd22d..aea7de8 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java @@ -59,6 +59,7 @@ public class RestoreBackupRunnable implements Runnable { MakeBackupRunnableFactory.create( BackupContext.Builder .newBackupContextBuilder() + .saveServer() .setServer(ctx.server()) .setInitiator(ActionInitiator.Restore) .setComment("Old_World" + (ctx.comment() != null ? "_" + ctx.comment() : "")) diff --git a/src/main/resources/assets/textile_backup/lang/en_us.json b/src/main/resources/assets/textile_backup/lang/en_us.json index 55223de..7f92d1b 100644 --- a/src/main/resources/assets/textile_backup/lang/en_us.json +++ b/src/main/resources/assets/textile_backup/lang/en_us.json @@ -24,7 +24,7 @@ "text.autoconfig.textile_backup.option.perWorldBackup": "Use separate folders for different worlds", - "text.autoconfig.textile_backup.option.path": "Path to backup folder", + "text.autoconfig.textile_backup.option.backupDirectoryPath": "Path to backup folder", "text.autoconfig.textile_backup.option.fileBlacklist": "Blacklisted files", @@ -36,7 +36,7 @@ "text.autoconfig.textile_backup.option.maxAge.@Tooltip": "In seconds since creation", "text.autoconfig.textile_backup.option.maxSize": "Max size of backup folder", - "text.autoconfig.textile_backup.option.maxSize.@Tooltip": "In KBytes", + "text.autoconfig.textile_backup.option.maxSize.@Tooltip": "In KiBytes", "text.autoconfig.textile_backup.option.compression": "Compression level", "text.autoconfig.textile_backup.option.compression.@Tooltip": "Only affects zip", From 8427eebfcc78521951c1c443027724bd346486a7 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sun, 6 Nov 2022 11:00:14 +0100 Subject: [PATCH 23/24] Added 'latest' keyword to restore (#85) RestoreHelper::getAvailableBackups now returns sorted LinkedList --- .../commands/FileSuggestionProvider.java | 6 ++ .../commands/manage/ListBackupsCommand.java | 2 +- .../restore/RestoreBackupCommand.java | 55 +++++++++++-------- .../core/restore/RestoreHelper.java | 17 +++++- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java index e4ef038..319e341 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java +++ b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java @@ -62,6 +62,12 @@ public final class FileSuggestionProvider implements SuggestionProvider "#" + s).orElse(""))) + ); + return builder.buildFuture(); } } diff --git a/src/main/java/net/szum123321/textile_backup/commands/manage/ListBackupsCommand.java b/src/main/java/net/szum123321/textile_backup/commands/manage/ListBackupsCommand.java index 22f363b..962709e 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/manage/ListBackupsCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/manage/ListBackupsCommand.java @@ -34,7 +34,7 @@ public class ListBackupsCommand { public static LiteralArgumentBuilder register() { return CommandManager.literal("list") .executes(ctx -> { StringBuilder builder = new StringBuilder(); - List backups = RestoreHelper.getAvailableBackups(ctx.getSource().getServer()); + var backups = RestoreHelper.getAvailableBackups(ctx.getSource().getServer()); if(backups.size() == 0) { builder.append("There a no backups available for this world."); diff --git a/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java b/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java index 2446f0a..b53f18a 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/restore/RestoreBackupCommand.java @@ -36,6 +36,7 @@ import net.szum123321.textile_backup.core.restore.RestoreHelper; import javax.annotation.Nullable; import java.time.LocalDateTime; import java.time.format.DateTimeParseException; +import java.util.Objects; import java.util.Optional; public class RestoreBackupCommand { @@ -65,6 +66,7 @@ public class RestoreBackupCommand { log.sendInfo(source, "To restore given backup you have to provide exact creation time in format:"); log.sendInfo(source, "[YEAR]-[MONTH]-[DAY]_[HOUR].[MINUTE].[SECOND]"); log.sendInfo(source, "Example: /backup restore 2020-08-05_10.58.33"); + log.sendInfo(source, "You may also type '/backup restore latest' to restore the freshest backup"); return 1; }); @@ -78,35 +80,40 @@ public class RestoreBackupCommand { } LocalDateTime dateTime; + Optional backupFile; - try { - dateTime = LocalDateTime.from(Globals.defaultDateTimeFormatter.parse(file)); - } catch (DateTimeParseException e) { - throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e); + if(Objects.equals(file, "latest")) { + backupFile = RestoreHelper.getLatestAndLockIfPresent(source.getServer()); + dateTime = backupFile.map(RestoreableFile::getCreationTime).orElse(LocalDateTime.now()); + } else { + try { + dateTime = LocalDateTime.from(Globals.defaultDateTimeFormatter.parse(file)); + } catch (DateTimeParseException e) { + throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e); + } + + backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getServer()); } - Optional backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getServer()); - - if(backupFile.isPresent()) { - log.info("Found file to restore {}", backupFile.get().getFile().getFileName().toString()); - } else { + if(backupFile.isEmpty()) { log.sendInfo(source, "No file created on {} was found!", dateTime.format(Globals.defaultDateTimeFormatter)); return -1; + } else { + log.info("Found file to restore {}", backupFile.get().getFile().getFileName().toString()); + + Globals.INSTANCE.setAwaitThread( + RestoreHelper.create( + RestoreContext.Builder.newRestoreContextBuilder() + .setCommandSource(source) + .setFile(backupFile.get()) + .setComment(comment) + .build() + ) + ); + + Globals.INSTANCE.getAwaitThread().get().start(); + + return 1; } - - Globals.INSTANCE.setAwaitThread( - RestoreHelper.create( - RestoreContext.Builder.newRestoreContextBuilder() - .setCommandSource(source) - .setFile(backupFile.get()) - .setComment(comment) - .build() - ) - ); - - Globals.INSTANCE.getAwaitThread().get().start(); - - return 1; } - } diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java index de1fa44..075e9fd 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java @@ -50,6 +50,17 @@ public class RestoreHelper { return optionalFile; } + public static Optional getLatestAndLockIfPresent( MinecraftServer server) { + var available = RestoreHelper.getAvailableBackups(server); + + if(available.isEmpty()) return Optional.empty(); + else { + var latest = available.getLast(); + Globals.INSTANCE.setLockedFile(latest.getFile()); + return Optional.of(latest); + } + } + public static AwaitThread create(RestoreContext ctx) { if(ctx.initiator() == ActionInitiator.Player) log.info("Backup restoration was initiated by: {}", ctx.commandSource().getName()); @@ -67,11 +78,11 @@ public class RestoreHelper { ); } - public static List getAvailableBackups(MinecraftServer server) { + public static LinkedList getAvailableBackups(MinecraftServer server) { Path root = Utilities.getBackupRootPath(Utilities.getLevelName(server)); - return RestoreableFile.applyOnFiles(root, List.of(), + return RestoreableFile.applyOnFiles(root, new LinkedList<>(), e -> log.error("Error while listing available backups", e), - s -> s.collect(Collectors.toList())); + s -> s.sorted().collect(Collectors.toCollection(LinkedList::new))); } } \ No newline at end of file From aaf9a545231dc2f8481140c13b821105ed4832c5 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Sun, 6 Nov 2022 11:02:02 +0100 Subject: [PATCH 24/24] dep update + version bump + added testmod --- build.gradle | 11 ++++++ gradle.properties | 12 +++---- .../textile_backup/TextileBackupTest.java | 10 ++++++ src/test/resources/fabric.mod.json | 35 +++++++++++++++++++ .../resources/textile_backup-test.mixins.json | 12 +++++++ 5 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 src/test/java/net/szum123321/test/textile_backup/TextileBackupTest.java create mode 100644 src/test/resources/fabric.mod.json create mode 100644 src/test/resources/textile_backup-test.mixins.json diff --git a/build.gradle b/build.gradle index 6d92a9e..72e04cd 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,17 @@ repositories { mavenCentral() } +loom { + runs { + testServer { + server() + ideConfigGenerated project.rootProject == project + name = "Testmod Server" + source sourceSets.test + } + } +} + dependencies { //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" diff --git a/gradle.properties b/gradle.properties index 310b6ac..3ed2600 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,17 +2,17 @@ org.gradle.jvmargs=-Xmx1G minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.8 -loader_version=0.14.9 +yarn_mappings=1.19.2+build.28 +loader_version=0.14.10 #Fabric api -fabric_version=0.60.0+1.19.2 +fabric_version=0.64.0+1.19.2 #Cloth Config -cloth_version=8.0.75 +cloth_version=8.2.88 #ModMenu -modmenu_version=4.0.5 +modmenu_version=4.1.0 #Lazy DFU for faster dev start lazydfu_version=v0.1.3 @@ -21,6 +21,6 @@ lazydfu_version=v0.1.3 pgzip_commit_hash=af5f5c297e735f3f2df7aa4eb0e19a5810b8aff6 # Mod Properties -mod_version = 2.4.0 +mod_version = 2.5.0 maven_group = net.szum123321 archives_base_name = textile_backup \ No newline at end of file diff --git a/src/test/java/net/szum123321/test/textile_backup/TextileBackupTest.java b/src/test/java/net/szum123321/test/textile_backup/TextileBackupTest.java new file mode 100644 index 0000000..bd646f2 --- /dev/null +++ b/src/test/java/net/szum123321/test/textile_backup/TextileBackupTest.java @@ -0,0 +1,10 @@ +package net.szum123321.test.textile_backup; + +import net.fabricmc.api.ModInitializer; + +public class TextileBackupTest implements ModInitializer { + @Override + public void onInitialize() { + + } +} diff --git a/src/test/resources/fabric.mod.json b/src/test/resources/fabric.mod.json new file mode 100644 index 0000000..809dace --- /dev/null +++ b/src/test/resources/fabric.mod.json @@ -0,0 +1,35 @@ +{ + "schemaVersion": 1, + "id": "textile_backup", + "version": "${version}", + + "name": "Textile Backup Test", + "authors": [ + "Szum123321" + ], + "contact": { + "homepage": "https://www.curseforge.com/minecraft/mc-mods/textile-backup", + "issues": "https://github.com/Szum123321/textile_backup/issues", + "sources": "https://github.com/Szum123321/textile_backup" + }, + + "license": "GPLv3", + + "environment": "*", + "entrypoints": { + "main": [ + "net.szum123321.test.textile_backup.TextileBackupTest" + ] + }, + "mixins": [ + ], + + "depends": { + "fabricloader": ">=0.14.6", + "fabric": "*", + "minecraft": ">=1.19.1", + "cloth-config2": "*", + "java": ">=16", + "textile_backup": "*" + } +} \ No newline at end of file diff --git a/src/test/resources/textile_backup-test.mixins.json b/src/test/resources/textile_backup-test.mixins.json new file mode 100644 index 0000000..f858f63 --- /dev/null +++ b/src/test/resources/textile_backup-test.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "package": "net.szum123321.test.textile_backup.mixin", + "compatibilityLevel": "JAVA_16", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +}