TODO update, gui: jdoc + small rename
[fanfix.git] / src / be / nikiroo / fanfix / library / CacheLibrary.java
index a9063308f8faf2ca0741c22b0e2cb21ea198ef96..c8721ddae3719cae169e00112efc1308d76177a1 100644 (file)
@@ -112,14 +112,31 @@ public class CacheLibrary extends BasicLibrary {
 
        @Override
        public Image getSourceCover(String source) {
-               // no cache for the source cover
-               return lib.getSourceCover(source);
+               Image custom = getCustomSourceCover(source);
+               if (custom != null) {
+                       return custom;
+               }
+
+               return cacheLib.getSourceCover(source);
+       }
+
+       @Override
+       public Image getCustomSourceCover(String source) {
+               Image custom = cacheLib.getCustomSourceCover(source);
+               if (custom == null) {
+                       custom = lib.getCustomSourceCover(source);
+                       if (custom != null) {
+                               cacheLib.setSourceCover(source, custom);
+                       }
+               }
+
+               return custom;
        }
 
        @Override
        public void setSourceCover(String source, String luid) {
                lib.setSourceCover(source, luid);
-               cacheLib.setSourceCover(source, getSourceCover(source));
+               cacheLib.setSourceCover(source, getCover(luid));
        }
 
        @Override
@@ -232,6 +249,9 @@ public class CacheLibrary extends BasicLibrary {
 
        /**
         * Clear the {@link Story} from the cache.
+        * <p>
+        * The next time we try to retrieve the {@link Story}, it may be required to
+        * cache it again.
         * 
         * @param luid
         *            the story to clear
@@ -242,7 +262,6 @@ public class CacheLibrary extends BasicLibrary {
        public void clearFromCache(String luid) throws IOException {
                if (isCached(luid)) {
                        cacheLib.delete(luid);
-                       deleteInfo(luid);
                }
        }