Fix change source update
[fanfix.git] / src / be / nikiroo / fanfix / library / CacheLibrary.java
index f665e383cad2f43f6c0b1807d56e5fdb69705b13..2ef5b1ebaf1febb82fd2566290deb2648f794138 100644 (file)
@@ -3,6 +3,7 @@ package be.nikiroo.fanfix.library;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
+import java.net.URL;
 import java.util.List;
 
 import be.nikiroo.fanfix.Instance;
@@ -45,6 +46,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) {
@@ -138,7 +144,7 @@ public class CacheLibrary extends BasicLibrary {
                pg.addProgress(pgCacheLib, 1);
 
                story = lib.save(story, luid, pgLib);
-               story = cacheLib.save(story, luid, pgCacheLib);
+               story = cacheLib.save(story, story.getMeta().getLuid(), pgCacheLib);
 
                clearCache();
 
@@ -174,6 +180,8 @@ public class CacheLibrary extends BasicLibrary {
                lib.changeSource(luid, newSource, pgOrig);
                pgOrig.done();
 
+               getInfo(luid).setSource(newSource);
+
                pg.done();
        }
 
@@ -206,6 +214,25 @@ public class CacheLibrary extends BasicLibrary {
                }
        }
 
+       @Override
+       public Story imprt(URL url, Progress pg) throws IOException {
+               if (pg == null) {
+                       pg = new Progress();
+               }
+
+               Progress pgImprt = new Progress();
+               Progress pgCache = new Progress();
+               pg.setMinMax(0, 10);
+               pg.addProgress(pgImprt, 7);
+               pg.addProgress(pgCache, 3);
+
+               Story story = lib.imprt(url, pgImprt);
+               cacheLib.save(story, story.getMeta().getLuid(), pgCache);
+
+               pg.done();
+               return story;
+       }
+
        // All the following methods are only used by Save and Delete in
        // BasicLibrary: