Fix cover file not sent over wire
authorNiki Roo <niki@nikiroo.be>
Sat, 2 Dec 2017 14:03:51 +0000 (15:03 +0100)
committerNiki Roo <niki@nikiroo.be>
Sat, 2 Dec 2017 14:03:51 +0000 (15:03 +0100)
src/be/nikiroo/fanfix/library/BasicLibrary.java
src/be/nikiroo/fanfix/output/BasicOutput.java
src/be/nikiroo/fanfix/output/Cbz.java
src/be/nikiroo/fanfix/output/Epub.java
src/be/nikiroo/fanfix/output/Html.java

index 66fb94355b538a94c900279bf0278675e6e5d9e3..4c32e3c2a6cbb68d85efb17a3df113026c82ef4d 100644 (file)
@@ -319,15 +319,19 @@ abstract public class BasicLibrary {
                                        if (type != null) {
                                                story = BasicSupport.getSupport(type).process(url,
                                                                pgProcess);
+                                               // Because we do not want to clear the meta cache:
+                                               meta.setCover(story.getMeta().getCover());
                                                story.setMeta(meta);
+                                               //
                                        } else {
                                                throw new IOException("Unknown type: " + meta.getType());
                                        }
                                } 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("Cannot load file from library: "
+                                                                       + file, e));
                                } finally {
                                        pgProcess.done();
                                        pg.done();
index 036a1564d0a594eae2e4d758f0dd16f40a3fcd44..30c2ac66642d2608391b8543af76a9366e679b9e 100644 (file)
@@ -240,6 +240,25 @@ public abstract class BasicOutput {
                return type;
        }
 
+       /**
+        * Enable the creation of a .info file next to the resulting processed file.
+        * 
+        * @return TRUE to enable it
+        */
+       protected boolean isWriteInfo() {
+               return writeInfo;
+       }
+
+       /**
+        * Enable the creation of a cover file next to the resulting processed file
+        * if possible.
+        * 
+        * @return TRUE to enable it
+        */
+       protected boolean isWriteCover() {
+               return writeCover;
+       }
+
        /**
         * The output type.
         * 
index c70cc4123d3e05970d9a36ea29d0da089ecbb98c..8853c7695a2c6ac94883f6b8d1b80146e0710d3f 100644 (file)
@@ -27,7 +27,8 @@ class Cbz extends BasicOutput {
                dir.mkdir();
                try {
                        // will also save the images!
-                       new InfoText().process(story, dir, targetNameOrig);
+                       BasicOutput.getOutput(OutputType.TEXT, isWriteInfo()).process(
+                                       story, dir, targetNameOrig);
 
                        InfoCover.writeInfo(dir, targetNameOrig, story.getMeta());
                        if (story.getMeta() != null && !story.getMeta().isFakeCover()) {
index 2c47dcbcad68c5d12c2626f22b0771a867eabcd3..1ff6888ac42e13a185b2e1bda96b3ab9c552aa3d 100644 (file)
@@ -44,7 +44,8 @@ class Epub extends BasicOutput {
                // "Originals"
                File data = new File(tmpDir, "DATA");
                data.mkdir();
-               new InfoText().process(story, data, targetNameOrig);
+               BasicOutput.getOutput(OutputType.TEXT, isWriteInfo()).process(story,
+                               data, targetNameOrig);
                InfoCover.writeInfo(data, targetNameOrig, story.getMeta());
                IOUtils.writeSmallFile(data, "version", "3.0");
 
index 581c9495e7ccbf7d7ebf6ca5da2acb56fe73d175..f5fbb831c51cf063d856e89bbe095a687de107f7 100644 (file)
@@ -37,7 +37,8 @@ class Html extends BasicOutput {
                // write a copy of the originals inside
                InfoCover.writeInfo(dir, targetName, story.getMeta());
                InfoCover.writeCover(dir, targetName, story.getMeta());
-               new InfoText().process(story, dir, targetNameOrig);
+               BasicOutput.getOutput(OutputType.TEXT, isWriteInfo()).process(story,
+                               dir, targetNameOrig);
 
                target = new File(targetDir, targetName + getDefaultExtension(true));