X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2Fcache%2FManageCacheFunction.java;h=5431e9eedca9b3c1bce1b5705479e850f4f536d2;hb=0a2480df5845e2d7190dfdec9b2653b1609e853d;hp=65565987529d3885d72a38d12a7b545317e22ed9;hpb=f1b92378a792131ac8fb33a869405851d5b2d1f7;p=GpsPrune.git diff --git a/tim/prune/function/cache/ManageCacheFunction.java b/tim/prune/function/cache/ManageCacheFunction.java index 6556598..5431e9e 100644 --- a/tim/prune/function/cache/ManageCacheFunction.java +++ b/tim/prune/function/cache/ManageCacheFunction.java @@ -273,6 +273,7 @@ public class ManageCacheFunction extends GenericFunction implements Runnable */ public void run() { + // TODO: Maybe this can be speeded up so that it just finds the tilesets first and then gets the details later // Check if directory has anything in it _model = new TileCacheModel(_cacheDir); _model.buildTileSets(); @@ -365,8 +366,7 @@ public class ManageCacheFunction extends GenericFunction implements Runnable if (totalDeleted > 0) { // Show confirmation message - JOptionPane.showMessageDialog(_dialog, I18nManager.getText("dialog.diskcache.deleted1") - + " " + totalDeleted + " " + I18nManager.getText("dialog.diskcache.deleted2"), + JOptionPane.showMessageDialog(_dialog, I18nManager.getTextWithNumber("dialog.diskcache.deleted", totalDeleted), I18nManager.getText(getNameKey()), JOptionPane.INFORMATION_MESSAGE); // reload model _cards.first(_cardPanel); @@ -395,18 +395,13 @@ public class ManageCacheFunction extends GenericFunction implements Runnable if (subdir.isDirectory()) { numDeleted += deleteFilesFrom(subdir, inMaxDays); } - else if (subdir.isFile() && subdir.exists()) + else if (subdir.isFile() && subdir.exists() && _TILEFILTER.accept(subdir)) { - boolean isTileFile = _TILEFILTER.accept(subdir); - boolean isBadFile = !isTileFile && subdir.getName().toLowerCase().endsWith("png"); - if (isTileFile || isBadFile) + long fileAge = (now - subdir.lastModified()) / 1000 / 60 / 60 / 24; + if (inMaxDays < 0 || fileAge > inMaxDays) { - long fileAge = (now - subdir.lastModified()) / 1000 / 60 / 60 / 24; - if (inMaxDays < 0 || fileAge > inMaxDays || isBadFile) - { - if (subdir.delete()) { - numDeleted++; - } + if (subdir.delete()) { + numDeleted++; } } }