Auto cache cleaning + better err in ImageUtilsAnd
[nikiroo-utils.git] / src / be / nikiroo / utils / Cache.java
index 2b32d78d67c03d20ba94148b8f92b2f7bdabda23..bba88bb4b48f7e970039002393a72a47d50081cf 100644 (file)
@@ -135,7 +135,12 @@ public class Cache {
         */
        private boolean check(File cached, boolean allowTooOld, boolean stable) {
                if (cached.exists() && cached.isFile()) {
-                       if (allowTooOld || !isOld(cached, stable)) {
+                       if (!allowTooOld && isOld(cached, stable)) {
+                               if (!cached.delete()) {
+                                       tracer.error("Cannot delete temporary file: "
+                                                       + cached.getAbsolutePath());
+                               }
+                       } else {
                                return true;
                        }
                }