X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FCache.java;fp=src%2Fbe%2Fnikiroo%2Futils%2FCache.java;h=13a50ea92219663a379eb58d7956237217a3f49a;hb=0988831f084e27de9927c1bb29e338e9263bfa42;hp=bba88bb4b48f7e970039002393a72a47d50081cf;hpb=59864f77f0b8d5a57f479152a3131093544af6b2;p=fanfix.git diff --git a/src/be/nikiroo/utils/Cache.java b/src/be/nikiroo/utils/Cache.java index bba88bb..13a50ea 100644 --- a/src/be/nikiroo/utils/Cache.java +++ b/src/be/nikiroo/utils/Cache.java @@ -47,8 +47,8 @@ public class Cache { public Cache(File dir, int hoursChanging, int hoursStable) throws IOException { this.dir = dir; - this.tooOldChanging = 1000 * 60 * 60 * hoursChanging; - this.tooOldStable = 1000 * 60 * 60 * hoursStable; + this.tooOldChanging = 1000L * 60 * 60 * hoursChanging; + this.tooOldStable = 1000L * 60 * 60 * hoursStable; if (dir != null && !dir.exists()) { dir.mkdirs(); @@ -174,16 +174,19 @@ public class Cache { */ private int clean(boolean onlyOld, File cacheDir) { int num = 0; - for (File file : cacheDir.listFiles()) { - if (file.isDirectory()) { - num += clean(onlyOld, file); - } else { - if (!onlyOld || isOld(file, true)) { - if (file.delete()) { - num++; - } else { - tracer.error("Cannot delete temporary file: " - + file.getAbsolutePath()); + File[] files = cacheDir.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + num += clean(onlyOld, file); + } else { + if (!onlyOld || isOld(file, true)) { + if (file.delete()) { + num++; + } else { + tracer.error("Cannot delete temporary file: " + + file.getAbsolutePath()); + } } } }