Bug fixes regarding cache miss/hit
authorNiki Roo <niki@nikiroo.be>
Sun, 10 Dec 2017 17:41:22 +0000 (18:41 +0100)
committerNiki Roo <niki@nikiroo.be>
Sun, 10 Dec 2017 17:41:22 +0000 (18:41 +0100)
src/be/nikiroo/fanfix/DataLoader.java
src/be/nikiroo/fanfix/library/CacheLibrary.java
src/be/nikiroo/fanfix/supported/BasicSupport.java

index 4a42218c5f21058bd2fffe5384ea9585df2a2306..e2af0709bb316e06ac78634d6b3aa877082ccc33 100644 (file)
@@ -145,7 +145,7 @@ public class DataLoader {
                                                downloadCache.save(in, originalUrl);
                                                // ..But we want a resetable stream
                                                in.close();
-                                               in = downloadCache.load(originalUrl, false, stable);
+                                               in = downloadCache.load(originalUrl, true, stable);
                                        } else {
                                                InputStream resetIn = IOUtils.forceResetableStream(in);
                                                if (resetIn != in) {
index 26204156b4d587cb7353851de1a8ea8af7e12b84..ee22e3439cc6d38001b6c36885106641fba0112a 100644 (file)
@@ -124,20 +124,13 @@ public class CacheLibrary extends BasicLibrary {
 
        @Override
        protected void invalidateInfo(String luid) {
-               List<MetaData> metas = this.metas;
-
                if (luid == null) {
-                       this.metas = null;
+                       metas = null;
                } else if (metas != null) {
                        MetaData meta = lib.getInfo(luid);
                        for (int i = 0; i < metas.size(); i++) {
                                if (metas.get(i).getLuid().equals(luid)) {
-                                       if (meta != null) {
-                                               metas.set(i, meta);
-                                               meta = null;
-                                       } else {
-                                               metas.remove(i--);
-                                       }
+                                       metas.remove(i--);
                                }
                        }
 
@@ -179,13 +172,9 @@ public class CacheLibrary extends BasicLibrary {
                }
                lib.delete(luid);
 
-               List<MetaData> metas = this.metas;
-               if (metas != null) {
-                       for (int i = 0; i < metas.size(); i++) {
-                               if (metas.get(i).getLuid().equals(luid)) {
-                                       metas.set(i, lib.getInfo(luid));
-                               }
-                       }
+               MetaData meta = getInfo(luid);
+               if (meta != null) {
+                       metas.remove(meta);
                }
        }
 
@@ -263,6 +252,8 @@ public class CacheLibrary extends BasicLibrary {
                Story story = lib.imprt(url, pgImprt);
                cacheLib.save(story, story.getMeta().getLuid(), pgCache);
 
+               invalidateInfo(story.getMeta().getLuid());
+
                pg.done();
                return story;
        }
index f16cdc7b6453ac00753bb479850ab7eb2edcafc5..0c127aa21a17d59631f6d3200e31ea08a582f077 100644 (file)
@@ -466,7 +466,7 @@ public abstract class BasicSupport {
                                        if (chap.getValue() != null) {
                                                setCurrentReferer(chap.getValue());
                                                chapIn = Instance.getCache().open(chap.getValue(),
-                                                               this, true);
+                                                               this, false);
                                        }
                                        pgChaps.setProgress(i * 100);
                                        try {