From: Niki Roo Date: Sat, 2 Dec 2017 14:01:56 +0000 (+0100) Subject: Improve CacheLibrary Save() X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=03c1cedeecd924073580fff4a8e6665dd5cf8cd5;p=nikiroo-utils.git Improve CacheLibrary Save() --- diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index da6f56d..f665e38 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -126,8 +126,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, luid, pgCacheLib); + clearCache(); + return story; }