Fix remote saving
[fanfix.git] / src / be / nikiroo / fanfix / library / CacheLibrary.java
index da6f56d3fa8fac1a097ad6df9ee47ac3f0dc5b42..28f568210bbcf137a1690989cad15fac50ae72e7 100644 (file)
@@ -45,6 +45,11 @@ public class CacheLibrary extends BasicLibrary {
                return lib.getLibraryName();
        }
 
+       @Override
+       public Status getStatus() {
+               return lib.getStatus();
+       }
+
        @Override
        protected List<MetaData> getMetas(Progress pg) {
                if (pg == null) {
@@ -126,8 +131,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;
        }