small cached lib fixes
authorNiki Roo <niki@nikiroo.be>
Sun, 24 Mar 2019 14:14:14 +0000 (15:14 +0100)
committerNiki Roo <niki@nikiroo.be>
Sun, 24 Mar 2019 14:14:14 +0000 (15:14 +0100)
src/be/nikiroo/fanfix/library/BasicLibrary.java
src/be/nikiroo/fanfix/library/CacheLibrary.java
src/be/nikiroo/fanfix/library/LocalLibrary.java

index b8b8185cd50f75b915d732901ce8a79814bb9727..4abaefa34f099943119bbb9009dd9e42bf42ac35 100644 (file)
@@ -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();
index 74af1b682c3ac21a982a7af0407b7e58edb322c4..bafaf9461a65b60a66a760eee66a9c3fa5d275bd 100644 (file)
@@ -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();
 
index bd9fe07cf7d720aae04cb04da884695e9a01e41d..59310fdc4f906b3247efb2b796e887c94666c41b 100644 (file)
@@ -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
         */