diff options
author | Keuin <[email protected]> | 2021-01-21 12:13:48 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2021-01-21 12:15:18 +0800 |
commit | 821b497a256e0c2825a78c0b070ee3398f79a509 (patch) | |
tree | 1dbb4abf3a818ebb773f736511ba5ff3d9916694 /src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java | |
parent | 64345efb5f4397993fbc9f2a2102ebcd3fe9f125 (diff) |
Fix minor bug in ZipUtil. Do some clean if backup is failed. Small code refactor.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java index b38921d..0d9cb65 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java @@ -33,6 +33,7 @@ public class BackupOperation extends InvokableAsyncBlockingOperation { protected void async() { String backupSaveDirectory = ""; MinecraftServer server = context.getSource().getMinecraftServer(); + boolean success = false; // only success when everything is done try { //// Do our main backup logic @@ -44,11 +45,12 @@ public class BackupOperation extends InvokableAsyncBlockingOperation { // Backup BackupFeedback result = configuredBackupMethod.backup(); - if (result.isSuccess()) { - // Restore old auto-save switch stat + success = result.isSuccess(); + if (success) { + // Restore previous auto-save switch stat server.getWorlds().forEach(world -> world.savingDisabled = oldWorldsSavingDisabled.getOrDefault(world, true)); - // Print finish message: time elapsed and file size + // Finish. Print time elapsed and file size long timeElapsedMillis = System.currentTimeMillis() - startTime; String msgText = String.format("Backup finished. Time elapsed: %.2fs. ", timeElapsedMillis / 1000.0) + result.getFeedback(); PrintUtil.msgInfo(context, msgText, true); |