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