X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FLocalLibrary.java;h=eafd18a6ecf642317c9e35c1e8e1c25aeea0ec5b;hb=cf45a4c44b472d0e1bbbcbc9891020366e99364c;hp=584fa1ed2c7b9834d2afba224fef96dad537d95b;hpb=e1de8087ab1623f7624018af905ea3bb0ef45802;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/LocalLibrary.java b/src/be/nikiroo/fanfix/library/LocalLibrary.java index 584fa1e..eafd18a 100644 --- a/src/be/nikiroo/fanfix/library/LocalLibrary.java +++ b/src/be/nikiroo/fanfix/library/LocalLibrary.java @@ -123,6 +123,10 @@ public class LocalLibrary extends BasicLibrary { public Image getCover(String luid) { MetaData meta = getInfo(luid); if (meta != null) { + if (meta.getCover() != null) { + return meta.getCover(); + } + File[] files = getStories(null).get(meta); if (files != null) { File infoFile = files[0]; @@ -224,18 +228,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(); } } @@ -256,7 +265,9 @@ public class LocalLibrary extends BasicLibrary { * the cover image */ synchronized void setSourceCover(String source, Image coverImage) { - File cover = new File(getExpectedDir(source), ".cover"); + File dir = getExpectedDir(source); + dir.mkdirs(); + File cover = new File(dir, ".cover"); try { Instance.getCache().saveAsImage(coverImage, cover, true); if (sourceCovers != null) {