From e59bdf4ac0b66ce683be1bbc36852bfce6f70a63 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sun, 4 Oct 2020 13:43:15 +0800 Subject: Pump up --- .../kbackupfabric/operation/BackupOperation.java | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java') diff --git a/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java index 4c08d14..071726b 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java @@ -56,21 +56,23 @@ public class BackupOperation extends InvokableAsyncBlockingOperation { String levelPath = getLevelPath(server); String backupFileName = getBackupFileName(backupName); - backupMethod.backup(backupName,levelPath,backupSaveDirectory); - - // Restore old autosave switch stat - server.getWorlds().forEach(world -> world.savingDisabled = oldWorldsSavingDisabled.getOrDefault(world, true)); - - // Print finish message: time elapsed and file size - 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) { + if(backupMethod.backup(backupName,levelPath,backupSaveDirectory)) { + // Restore old autosave switch stat + server.getWorlds().forEach(world -> world.savingDisabled = oldWorldsSavingDisabled.getOrDefault(world, true)); + + // Print finish message: time elapsed and file size + 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) { + } + PrintUtil.msgInfo(context, msgText, true); + } else { + // failed + PrintUtil.msgErr(context, "Backup operation failed. No further information."); } - PrintUtil.msgInfo(context, msgText, true); - } catch (SecurityException e) { msgInfo(context, String.format("Failed to create backup saving directory: %s. Failed to backup.", backupSaveDirectory)); } catch (IOException e) { -- cgit v1.2.3