Allow IOError when saving CBZ
[fanfix.git] / src / be / nikiroo / fanfix / output / Text.java
index ee72385b32220c479e1e03ad2d8a378f59539e49..4a45e5430fba9465b1e92a590bcae9cc18b28360 100644 (file)
@@ -17,6 +17,7 @@ import be.nikiroo.fanfix.data.Story;
 class Text extends BasicOutput {
        protected BufferedWriter writer;
        protected File targetDir;
+       private boolean nextParaIsCover = true;
 
        @Override
        public File process(Story story, File targetDir, String targetName)
@@ -104,8 +105,16 @@ class Text extends BasicOutput {
        protected void writeParagraphHeader(Paragraph para) throws IOException {
                if (para.getType() == ParagraphType.IMAGE) {
                        File file = new File(targetDir, getCurrentImageBestName(true));
-                       Instance.getCache().saveAsImage(para.getContentImage(), file);
+                       try {
+                               Instance.getCache().saveAsImage(para.getContentImage(), file,
+                                               nextParaIsCover);
+                       } catch (IOException e) {
+                               Instance.getTraceHandler().error(
+                                               new IOException("Cannot save an image", e));
+                       }
                }
+
+               nextParaIsCover = false;
        }
 
        @Override