fix remote default covers
[fanfix.git] / src / be / nikiroo / fanfix / library / CacheLibrary.java
index a9063308f8faf2ca0741c22b0e2cb21ea198ef96..a550740bafa7a9105d271ef9dd7df53515651d6e 100644 (file)
@@ -112,14 +112,36 @@ public class CacheLibrary extends BasicLibrary {
 
        @Override
        public Image getSourceCover(String source) {
-               // no cache for the source cover
+               Image custom = getCustomSourceCover(source);
+               if (custom != null) {
+                       return custom;
+               }
+
+               Image cached = cacheLib.getSourceCover(source);
+               if (cached != null) {
+                       return cached;
+               }
+
                return lib.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 +254,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 +267,6 @@ public class CacheLibrary extends BasicLibrary {
        public void clearFromCache(String luid) throws IOException {
                if (isCached(luid)) {
                        cacheLib.delete(luid);
-                       deleteInfo(luid);
                }
        }