Improve CacheLibrary Save()
[fanfix.git] / src / be / nikiroo / fanfix / library / CacheLibrary.java
index d653332a73673aaff0bbce6b0128cb901c15b94b..f665e383cad2f43f6c0b1807d56e5fdb69705b13 100644 (file)
@@ -80,7 +80,7 @@ public class CacheLibrary extends BasicLibrary {
                                pgImport.done();
                                clearCache();
                        } catch (IOException e) {
-                               Instance.syserr(e);
+                               Instance.getTraceHandler().error(e);
                        }
 
                        pgImport.done();
@@ -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;
        }