Improve CacheLibrary Save()
authorNiki Roo <niki@nikiroo.be>
Sat, 2 Dec 2017 14:01:56 +0000 (15:01 +0100)
committerNiki Roo <niki@nikiroo.be>
Sat, 2 Dec 2017 14:01:56 +0000 (15:01 +0100)
src/be/nikiroo/fanfix/library/CacheLibrary.java

index da6f56d3fa8fac1a097ad6df9ee47ac3f0dc5b42..f665e383cad2f43f6c0b1807d56e5fdb69705b13 100644 (file)
@@ -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;
        }