From: Niki Roo Date: Sun, 24 Mar 2019 14:14:14 +0000 (+0100) Subject: small cached lib fixes X-Git-Tag: fanfix-2.0.0~6 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=d4449e9632aac4c20bdb9183cabb37b377270c41;p=fanfix.git small cached lib fixes --- diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index b8b8185..4abaefa 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -185,7 +185,7 @@ abstract public class BasicLibrary { /** * Set the author cover to the given story cover. * - * @param source + * @param author * the author to change * @param luid * the story LUID @@ -599,7 +599,8 @@ abstract public class BasicLibrary { * * @return the corresponding {@link Story} or NULL if not found */ - public synchronized Story getStory(String luid, MetaData meta, Progress pg) { + public synchronized Story getStory(String luid, + @SuppressWarnings("javadoc") MetaData meta, Progress pg) { if (pg == null) { pg = new Progress(); @@ -633,9 +634,10 @@ abstract public class BasicLibrary { } catch (IOException e) { // We should not have not-supported files in the // library - Instance.getTraceHandler() - .error(new IOException("Cannot load file from library: " - + file, e)); + Instance.getTraceHandler().error( + new IOException(String.format( + "Cannot load file of type '%s' from library: %s", + meta.getType(), file), e)); } finally { pgProcess.done(); pg.done(); diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index 74af1b6..bafaf94 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -67,27 +67,16 @@ public class CacheLibrary extends BasicLibrary { @Override public synchronized Story getStory(String luid, MetaData meta, Progress pg) { - String type = cacheLib.getOutputType(meta.isImageDocument()); - MetaData cachedMeta = meta.clone(); - cachedMeta.setType(type); - - return super.getStory(luid, cachedMeta, pg); - } - - @Override - public synchronized File getFile(final String luid, Progress pg) { if (pg == null) { pg = new Progress(); } Progress pgImport = new Progress(); Progress pgGet = new Progress(); - Progress pgRecall = new Progress(); - pg.setMinMax(0, 5); + pg.setMinMax(0, 4); pg.addProgress(pgImport, 3); pg.addProgress(pgGet, 1); - pg.addProgress(pgRecall, 1); if (!isCached(luid)) { try { @@ -102,6 +91,31 @@ public class CacheLibrary extends BasicLibrary { pgGet.done(); } + String type = cacheLib.getOutputType(meta.isImageDocument()); + MetaData cachedMeta = meta.clone(); + cachedMeta.setType(type); + + return cacheLib.getStory(luid, cachedMeta, pg); + } + + @Override + public synchronized File getFile(final String luid, Progress pg) { + if (pg == null) { + pg = new Progress(); + } + + Progress pgGet = new Progress(); + Progress pgRecall = new Progress(); + + pg.setMinMax(0, 5); + pg.addProgress(pgGet, 4); + pg.addProgress(pgRecall, 1); + + if (!isCached(luid)) { + getStory(luid, pgGet); + pgGet.done(); + } + File file = cacheLib.getFile(luid, pgRecall); pgRecall.done(); diff --git a/src/be/nikiroo/fanfix/library/LocalLibrary.java b/src/be/nikiroo/fanfix/library/LocalLibrary.java index bd9fe07..59310fd 100644 --- a/src/be/nikiroo/fanfix/library/LocalLibrary.java +++ b/src/be/nikiroo/fanfix/library/LocalLibrary.java @@ -410,15 +410,15 @@ public class LocalLibrary extends BasicLibrary { if (meta != null && meta.isImageDocument()) { return image; } - + return text; } - + /** * Return the default {@link OutputType} for this kind of {@link Story}. * * @param imageDocument - * TRUE for images document, FALSE for text documents + * TRUE for images document, FALSE for text documents * * @return the type */