diff options
author | Keuin <[email protected]> | 2020-10-04 13:43:15 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2020-10-04 13:43:15 +0800 |
commit | e59bdf4ac0b66ce683be1bbc36852bfce6f70a63 (patch) | |
tree | 6c8b97f97af857d2740e7b79d46349cc83a8c7dd /src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java | |
parent | d9c2af035ac2edb68bc8b6a1f94b7c772c3509c8 (diff) |
Pump up
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java | 30 |
1 files changed, 16 insertions, 14 deletions
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) { |