summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2020-11-30 13:15:15 +0800
committerkeuin <[email protected]>2020-11-30 13:15:15 +0800
commit61ade9adad4668494dfc32da7751e1b86251dc97 (patch)
treec220fe41d0691d7ad6ed08e51d351537fa220a4f /src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java
parente59bdf4ac0b66ce683be1bbc36852bfce6f70a63 (diff)
Implementing incremental backup
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java
index 071726b..d03c347 100644
--- a/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java
+++ b/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java
@@ -8,7 +8,6 @@ import com.keuin.kbackupfabric.util.PrintUtil;
import com.keuin.kbackupfabric.util.backup.builder.BackupFileNameBuilder;
import com.keuin.kbackupfabric.util.backup.formatter.BackupFileNameFormatter;
import com.mojang.brigadier.context.CommandContext;
-import com.sun.istack.internal.NotNull;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.world.World;
@@ -30,7 +29,7 @@ public class BackupOperation extends InvokableAsyncBlockingOperation {
private long startTime;
- public BackupOperation(@NotNull CommandContext<ServerCommandSource> context, @NotNull String backupName, @NotNull BackupMethod backupMethod, @NotNull BackupFileNameBuilder backupFileNameBuilder, @NotNull BackupFileNameFormatter backupFileNameFormatter) {
+ public BackupOperation(CommandContext<ServerCommandSource> context, String backupName, BackupMethod backupMethod) {
super("BackupWorker");
this.context = context;
this.backupName = backupName;
@@ -56,7 +55,8 @@ public class BackupOperation extends InvokableAsyncBlockingOperation {
String levelPath = getLevelPath(server);
String backupFileName = getBackupFileName(backupName);
- if(backupMethod.backup(backupName,levelPath,backupSaveDirectory)) {
+ BackupMethod.BackupResult result = backupMethod.backup(backupName,levelPath,backupSaveDirectory);
+ if(result.isSuccess()) {
// Restore old autosave switch stat
server.getWorlds().forEach(world -> world.savingDisabled = oldWorldsSavingDisabled.getOrDefault(world, true));
@@ -64,10 +64,7 @@ public class BackupOperation extends InvokableAsyncBlockingOperation {
long timeElapsedMillis = System.currentTimeMillis() - startTime;
String msgText = String.format("Backup finished. Time elapsed: %.2fs.", timeElapsedMillis / 1000.0);
File backupZipFile = new File(backupSaveDirectory, backupFileName);
- try {
- msgText += String.format(" File size: %s.", humanFileSize(backupZipFile.length()));
- } catch (SecurityException ignored) {
- }
+ msgText += String.format(" File size: %s.", humanFileSize(result.getBackupSizeBytes()));
PrintUtil.msgInfo(context, msgText, true);
} else {
// failed