From 6c2b1f555f810d5a0174f57a3564295ef8d251a0 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Fri, 13 Dec 2013 00:17:56 +0100 Subject: [PATCH] Improve CleanBackupsTask a bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Print proper file names to the console when the date could not be determined * Skip all directories * Skip every file that doesn’t have .zip in the file name --- .../gmail/nossr50/runnables/backups/CleanBackupsTask.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java index c27db6783..2c6fcb0b8 100644 --- a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java @@ -33,17 +33,16 @@ public class CleanBackupsTask extends BukkitRunnable { // Check files in backup folder from oldest to newest for (File file : BACKUP_DIR.listFiles()) { - if (!file.isFile()) { + if (!file.isFile() || file.isDirectory()) { continue; } amountTotal++; String fileName = file.getName(); - fileName = fileName.split("[.]")[0]; - Date date = getDate(fileName); + Date date = getDate(fileName.split("[.]")[0]); - if (date == null) { + if (!fileName.contains(".zip") || date == null) { mcMMO.p.debug("Could not determine date for file: " + fileName); continue; }