X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FCacheLibrary.java;h=38fb7b3193e1b13da59e2abc285d2a6bd0461dfa;hp=40128979ee4dcfdf318272077a99c014ab396097;hb=085a2f9a3a811a910de7c3011eb6f5ef2ab18aa0;hpb=2249988a85d0daeb952b4d2df63b838c9385143c diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index 4012897..38fb7b3 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -78,9 +78,7 @@ public class CacheLibrary extends BasicLibrary { try { cacheLib.imprt(lib, luid, pgImport); pgImport.done(); - Story story = cacheLib.getStory(luid, pgGet); - metas.remove(story.getMeta()); - metas.add(story.getMeta()); + clearCache(); } catch (IOException e) { Instance.syserr(e); } @@ -98,14 +96,26 @@ public class CacheLibrary extends BasicLibrary { @Override public BufferedImage getCover(final String luid) { - // Retrieve it from the cache if possible: if (isCached(luid)) { return cacheLib.getCover(luid); } + // We could update the cache here, but it's not easy return lib.getCover(luid); } + @Override + public BufferedImage getSourceCover(String source) { + // no cache for the source cover + return lib.getSourceCover(source); + } + + @Override + public void setSourceCover(String source, String luid) { + lib.setSourceCover(source, luid); + cacheLib.setSourceCover(source, getSourceCover(source)); + } + @Override protected void clearCache() { metas = null; @@ -123,17 +133,13 @@ public class CacheLibrary extends BasicLibrary { @Override public synchronized void delete(String luid) throws IOException { - cacheLib.delete(luid); + if (isCached(luid)) { + cacheLib.delete(luid); + } lib.delete(luid); clearCache(); } - @Override - public void setSourceCover(String source, String luid) { - cacheLib.setSourceCover(source, luid); - lib.setSourceCover(source, luid); - } - @Override public synchronized void changeSource(String luid, String newSource, Progress pg) throws IOException {