X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FCache.java;h=111fc769b9a5ded89c772d0ff2ede551cfcf080c;hp=393f634dc5a2b011f88b5e1103ab26d6293e8641;hb=805005449dacb1e7b825db63836bf100e472ddd0;hpb=f4053377fa15da2f11e82955bfab86e673fa371c diff --git a/src/be/nikiroo/utils/Cache.java b/src/be/nikiroo/utils/Cache.java index 393f634..111fc76 100644 --- a/src/be/nikiroo/utils/Cache.java +++ b/src/be/nikiroo/utils/Cache.java @@ -70,6 +70,10 @@ public class Cache { * the new traces handler */ public void setTraceHandler(TraceHandler tracer) { + if (tracer == null) { + tracer = new TraceHandler(false, false, false); + } + this.tracer = tracer; } @@ -89,7 +93,7 @@ public class Cache { */ public boolean check(URL url, boolean allowTooOld, boolean stable) { File file = getCached(url); - if (file.exists()) { + if (file.exists() && file.isFile()) { if (allowTooOld || !isOld(file, stable)) { return true; } @@ -190,7 +194,8 @@ public class Cache { * @return the opened resource if found, NULL if not */ private InputStream load(File cached, boolean allowTooOld, boolean stable) { - if (cached.exists() && (allowTooOld || !isOld(cached, stable))) { + if (cached.exists() && cached.isFile() + && (allowTooOld || !isOld(cached, stable))) { try { return new MarkableFileInputStream(new FileInputStream(cached)); } catch (FileNotFoundException e) {