Update nikiroo-utils, remove Instance.syserr/trace
[nikiroo-utils.git] / src / be / nikiroo / fanfix / DataLoader.java
index ef115c9d60a9b647147fe3dff06c9bf5d95a6283..2fd59d89764783cd9622fcc0249039dc012f1043 100644 (file)
@@ -99,8 +99,8 @@ public class DataLoader {
                // MUST NOT return null
                try {
                        InputStream in = cache.load(originalUrl, false, stable);
-                       Instance.trace("Cache " + (in != null ? "hit" : "miss") + ": "
-                                       + url);
+                       Instance.getTraceHandler().trace(
+                                       "Cache " + (in != null ? "hit" : "miss") + ": " + url);
 
                        if (in == null) {
                                try {
@@ -231,6 +231,8 @@ public class DataLoader {
                        ImageIO.write(ImageUtils.fromStream(in), Instance.getConfig()
                                        .getString(Config.IMAGE_FORMAT_CONTENT).toLowerCase(),
                                        target);
+               } catch (IOException e) {
+                       throw new IOException("Cannot write image " + url, e);
                } finally {
                        in.close();
                }
@@ -266,6 +268,18 @@ public class DataLoader {
                return cache.load(uniqueID, true, true);
        }
 
+       /**
+        * Remove the given resource from the cache.
+        * 
+        * @param uniqueID
+        *            a unique ID used to locate the cached resource
+        * 
+        * @return TRUE if it was removed
+        */
+       public boolean removeFromCache(String uniqueID) {
+               return cache.remove(uniqueID);
+       }
+
        /**
         * Clean the cache (delete the cached items).
         *