From cbd62024bf557bb4da3891435a4ce050cfc9fae7 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 10 Dec 2017 18:41:22 +0100 Subject: [PATCH] Bug fixes regarding cache miss/hit --- src/be/nikiroo/fanfix/DataLoader.java | 2 +- .../nikiroo/fanfix/library/CacheLibrary.java | 23 ++++++------------- .../fanfix/supported/BasicSupport.java | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/be/nikiroo/fanfix/DataLoader.java b/src/be/nikiroo/fanfix/DataLoader.java index 4a42218c..e2af0709 100644 --- a/src/be/nikiroo/fanfix/DataLoader.java +++ b/src/be/nikiroo/fanfix/DataLoader.java @@ -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) { diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index 26204156..ee22e343 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -124,20 +124,13 @@ public class CacheLibrary extends BasicLibrary { @Override protected void invalidateInfo(String luid) { - List 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 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; } diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport.java b/src/be/nikiroo/fanfix/supported/BasicSupport.java index f16cdc7b..0c127aa2 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport.java @@ -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 { -- 2.27.0