fix cover issue
authorNiki Roo <niki@nikiroo.be>
Sun, 10 Mar 2019 16:22:05 +0000 (17:22 +0100)
committerNiki Roo <niki@nikiroo.be>
Sun, 10 Mar 2019 16:22:05 +0000 (17:22 +0100)
src/be/nikiroo/fanfix/library/LocalLibrary.java
src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java

index 584fa1ed2c7b9834d2afba224fef96dad537d95b..50f9ac01fe902f272255e96da1facbd117a85178 100644 (file)
@@ -224,18 +224,23 @@ public class LocalLibrary extends BasicLibrary {
                File coverDir = new File(baseDir, source);
                if (coverDir.isDirectory()) {
                        File cover = new File(coverDir, ".cover.png");
-                       InputStream in;
-                       try {
-                               in = new FileInputStream(cover);
+                       if (cover.exists()) {
+                               InputStream in;
                                try {
-                                       sourceCovers.put(source, new Image(in));
-                               } finally {
-                                       in.close();
+                                       in = new FileInputStream(cover);
+                                       try {
+                                               sourceCovers.put(source, new Image(in));
+                                       } finally {
+                                               in.close();
+                                       }
+                               } catch (FileNotFoundException e) {
+                                       e.printStackTrace();
+                               } catch (IOException e) {
+                                       Instance.getTraceHandler().error(
+                                                       new IOException(
+                                                                       "Cannot load the existing custom source cover: "
+                                                                                       + cover, e));
                                }
-                       } catch (FileNotFoundException e) {
-                               e.printStackTrace();
-                       } catch (IOException e) {
-                               e.printStackTrace();
                        }
                }
 
index 72af3f1f9446e2e2e05e25f7424341786109faa2..dc275950c6297ae561504b18131a1853dfd1a2c5 100644 (file)
@@ -401,8 +401,6 @@ class GuiReaderBook extends JPanel {
                                                        .getSourceCover(meta.getSource());
                                }
 
-                               BufferedImage coverb = ImageUtilsAwt.fromImage(cover);
-
                                resizedImage = new BufferedImage(SPINE_WIDTH + COVER_WIDTH,
                                                SPINE_HEIGHT + COVER_HEIGHT + HOFFSET,
                                                BufferedImage.TYPE_4BYTE_ABGR);
@@ -410,6 +408,7 @@ class GuiReaderBook extends JPanel {
                                g.setColor(Color.white);
                                g.fillRect(0, HOFFSET, COVER_WIDTH, COVER_HEIGHT);
                                if (cover != null) {
+                                       BufferedImage coverb = ImageUtilsAwt.fromImage(cover);
                                        g.drawImage(coverb, 0, HOFFSET, COVER_WIDTH, COVER_HEIGHT,
                                                        null);
                                } else {