fix imported stories don't appear on screen
[fanfix.git] / src / be / nikiroo / fanfix / library / CacheLibrary.java
index 019acd210d1fb3b2263db468e2c21e6e6bfd1d69..e8743b63cd9d18ca0ef0ba3316aa204433b4bf34 100644 (file)
@@ -216,11 +216,17 @@ public class CacheLibrary extends BasicLibrary {
        @Override
        protected void updateInfo(MetaData meta) throws IOException {
                if (meta != null && metas != null) {
+                       boolean changed = false;
                        for (int i = 0; i < metas.size(); i++) {
                                if (metas.get(i).getLuid().equals(meta.getLuid())) {
                                        metas.set(i, meta);
+                                       changed = true;
                                }
                        }
+
+                       if (!changed) {
+                               metas.add(meta);
+                       }
                }
 
                cacheLib.updateInfo(meta);
@@ -345,7 +351,7 @@ public class CacheLibrary extends BasicLibrary {
        }
 
        @Override
-       public Story imprt(URL url, Progress pg) throws IOException {
+       public MetaData imprt(URL url, Progress pg) throws IOException {
                if (pg == null) {
                        pg = new Progress();
                }
@@ -356,13 +362,13 @@ public class CacheLibrary extends BasicLibrary {
                pg.addProgress(pgImprt, 7);
                pg.addProgress(pgCache, 3);
 
-               Story story = lib.imprt(url, pgImprt);
-               cacheLib.save(story, story.getMeta().getLuid(), pgCache);
-
-               updateInfo(story.getMeta());
-
+               MetaData meta = lib.imprt(url, pgImprt);
+               updateInfo(meta);
+               
+               clearFromCache(meta.getLuid());
+               
                pg.done();
-               return story;
+               return meta;
        }
 
        // All the following methods are only used by Save and Delete in