From 03c1cedeecd924073580fff4a8e6665dd5cf8cd5 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sat, 2 Dec 2017 15:01:56 +0100 Subject: [PATCH] Improve CacheLibrary Save() --- src/be/nikiroo/fanfix/library/CacheLibrary.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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; } -- 2.27.0