Improve CleanBackupsTask a bit

* 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
This commit is contained in:
TfT_02 2013-12-13 00:17:56 +01:00
parent cdcda03e92
commit 6c2b1f555f

View File

@ -33,17 +33,16 @@ public class CleanBackupsTask extends BukkitRunnable {
// Check files in backup folder from oldest to newest // Check files in backup folder from oldest to newest
for (File file : BACKUP_DIR.listFiles()) { for (File file : BACKUP_DIR.listFiles()) {
if (!file.isFile()) { if (!file.isFile() || file.isDirectory()) {
continue; continue;
} }
amountTotal++; amountTotal++;
String fileName = file.getName(); 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); mcMMO.p.debug("Could not determine date for file: " + fileName);
continue; continue;
} }