X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FCacheLibrary.java;h=2ef5b1ebaf1febb82fd2566290deb2648f794138;hb=1b9a09a2d3ddd4558c9f440392e50504421ddb2e;hp=d653332a73673aaff0bbce6b0128cb901c15b94b;hpb=e06632eecd6d4b194c3dbe6322097ee61457ec33;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index d653332..2ef5b1e 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) { @@ -80,7 +86,7 @@ public class CacheLibrary extends BasicLibrary { pgImport.done(); clearCache(); } catch (IOException e) { - Instance.syserr(e); + Instance.getTraceHandler().error(e); } pgImport.done(); @@ -126,8 +132,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; } @@ -160,6 +180,8 @@ public class CacheLibrary extends BasicLibrary { lib.changeSource(luid, newSource, pgOrig); pgOrig.done(); + getInfo(luid).setSource(newSource); + pg.done(); } @@ -192,6 +214,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: