X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=searchable%2FFanfiction.java;h=cbc927bcc2d981b028311be59fa2d1ba7c152542;hb=002972e9de731678035d56304d75a6d9e8233635;hp=c2dfd5d5714a8f4c5e388aeccf7a8cd51053f303;hpb=0fc81e6465aa9c1f1dfc19b532082220d609768a;p=nikiroo-utils.git diff --git a/searchable/Fanfiction.java b/searchable/Fanfiction.java index c2dfd5d..cbc927b 100644 --- a/searchable/Fanfiction.java +++ b/searchable/Fanfiction.java @@ -285,19 +285,22 @@ class Fanfiction extends BasicSearchable { String coverUrl = cover.absUrl("src"); try { - InputStream in = Instance.getCache().open( - new URL(coverUrl), getSupport(), true); + InputStream in = Instance.getInstance().getCache().open(new URL(coverUrl), getSupport(), true); try { - meta.setCover(new Image(in)); + Image img = new Image(in); + if (img.getSize() == 0) { + img.close(); + throw new IOException( + "Empty image not accepted"); + } + meta.setCover(img); } finally { in.close(); } } catch (Exception e) { // Should not happen on Fanfiction.net - Instance.getTraceHandler().error( - new Exception( - "Cannot download cover for Fanfiction story in search mode: " - + meta.getTitle(), e)); + Instance.getInstance().getTraceHandler().error(new Exception( + "Cannot download cover for Fanfiction story in search mode: " + meta.getTitle(), e)); } } } @@ -337,8 +340,7 @@ class Fanfiction extends BasicSearchable { } meta.setResume(getSupport().makeChapter(new URL(sourceUrl), 0, - Instance.getTrans().getString(StringId.DESCRIPTION), - resume)); + Instance.getInstance().getTrans().getString(StringId.DESCRIPTION), resume)); } // How are the tags ordered?