Adds some backup fixes
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good

Fixes a potential NullPointerException
Adds a check to make sure the backup location has enough available space
Adds a message when calculating backup size to make it clear that the software is not frozen
This commit is contained in:
Kristian Knarvik 2021-09-27 22:24:06 +02:00
parent 71e47acbb0
commit c26a3bc3b5
2 changed files with 15 additions and 5 deletions

View File

@ -64,11 +64,12 @@ public class BackupGUI implements ActionListener {
* @param progressPercent <p>The new percent of the progress bar</p>
*/
public static void updateProgress(String infoText, int progressPercent) {
if (progressTextArea == null || progressBar == null) {
return;
if (progressTextArea != null) {
progressTextArea.setText(infoText);
}
if (progressBar != null) {
progressBar.setValue(progressPercent);
}
progressTextArea.setText(infoText);
progressBar.setValue(progressPercent);
}
/**

View File

@ -114,11 +114,20 @@ public class BackupUtil {
}
gui.setStatus("Backup running...");
List<List<File>> serverFolders = getFoldersOfEnabledServers(path);
gui.setStatus("Calculating backup size...");
long backupFileSize = getFolderSize(gui, serverFolders);
long locationFreeSpace = path.getFreeSpace();
if (locationFreeSpace < (backupFileSize + 2048000000)) {
gui.setStatus("Not enough available space. " + (backupFileSize / 1000000) + "MB necessary, but only " +
(locationFreeSpace / 1000000) + "MB available");
backupRunning = false;
backupAborted = true;
return;
}
gui.setStatus("Backing up " + (backupFileSize / 1000000) + "MB");
performBackup(gui, serverFolders, backupFileSize);