X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FCacheLibrary.java;h=14113e4a583be24b5ea2a5ba71b04810220255c6;hb=edf79e5e06e8dc177cc13b9bad5bf848e6f9741d;hp=da6f56d3fa8fac1a097ad6df9ee47ac3f0dc5b42;hpb=62c63b0724f4bc45999cb2e7186b4b3ada479a0a;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index da6f56d..14113e4 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -3,6 +3,7 @@ package be.nikiroo.fanfix.library; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.net.URL; import java.util.List; import be.nikiroo.fanfix.Instance; @@ -45,6 +46,11 @@ public class CacheLibrary extends BasicLibrary { return lib.getLibraryName(); } + @Override + public Status getStatus() { + return lib.getStatus(); + } + @Override protected List getMetas(Progress pg) { if (pg == null) { @@ -96,6 +102,7 @@ public class CacheLibrary extends BasicLibrary { @Override public BufferedImage getCover(final String luid) { + // TODO: cache doesn't seem to work if (isCached(luid)) { return cacheLib.getCover(luid); } @@ -126,8 +133,22 @@ public class CacheLibrary extends BasicLibrary { @Override public synchronized Story save(Story story, String luid, Progress pg) throws IOException { - story = lib.save(story, luid, pg); + Progress pgLib = new Progress(); + Progress pgCacheLib = new Progress(); + + if (pg == null) { + pg = new Progress(); + } + + pg.setMinMax(0, 2); + pg.addProgress(pgLib, 1); + pg.addProgress(pgCacheLib, 1); + + story = lib.save(story, luid, pgLib); + story = cacheLib.save(story, story.getMeta().getLuid(), pgCacheLib); + clearCache(); + return story; } @@ -192,6 +213,25 @@ public class CacheLibrary extends BasicLibrary { } } + @Override + public Story imprt(URL url, Progress pg) throws IOException { + if (pg == null) { + pg = new Progress(); + } + + Progress pgImprt = new Progress(); + Progress pgCache = new Progress(); + pg.setMinMax(0, 10); + pg.addProgress(pgImprt, 7); + pg.addProgress(pgCache, 3); + + Story story = lib.imprt(url, pgImprt); + cacheLib.save(story, story.getMeta().getLuid(), pgCache); + + pg.done(); + return story; + } + // All the following methods are only used by Save and Delete in // BasicLibrary: