X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FWebLibrary.java;h=7381ae368661023aa3ac2a23c643d6f4461ac658;hb=HEAD;hp=7566877cebd48343b47c1764ed31045ee8de78dd;hpb=bf9c483d826523d68ab6b2dfc9e77b515813c09c;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/WebLibrary.java b/src/be/nikiroo/fanfix/library/WebLibrary.java index 7566877..7381ae3 100644 --- a/src/be/nikiroo/fanfix/library/WebLibrary.java +++ b/src/be/nikiroo/fanfix/library/WebLibrary.java @@ -133,7 +133,17 @@ public class WebLibrary extends BasicLibrary { * in case of I/O errors */ public void stop() throws IOException { - post(WebLibraryUrls.EXIT_URL, null).close(); + try { + post(WebLibraryUrls.EXIT_URL, null).close(); + } catch (Exception e) { + try { + Thread.sleep(200); + } catch (InterruptedException e1) { + } + if (getStatus() != Status.UNAVAILABLE) { + throw new IOException("Cannot exit the library", e); + } + } } @Override @@ -163,11 +173,12 @@ public class WebLibrary extends BasicLibrary { InputStream in = post(WebLibraryUrls.getStoryUrlCover(luid)); try { Image img = new Image(in); - if (img.getSize() > 0) { - return img; + if (img.getSize() == 0) { + img.close(); + img = null; } - return null; + return img; } finally { in.close(); } @@ -178,11 +189,12 @@ public class WebLibrary extends BasicLibrary { InputStream in = post(WebLibraryUrls.getCoverUrlSource(source)); try { Image img = new Image(in); - if (img.getSize() > 0) { - return img; + if (img.getSize() == 0) { + img.close(); + img = null; } - return null; + return img; } finally { in.close(); } @@ -193,11 +205,12 @@ public class WebLibrary extends BasicLibrary { InputStream in = post(WebLibraryUrls.getCoverUrlAuthor(author)); try { Image img = new Image(in); - if (img.getSize() > 0) { - return img; + if (img.getSize() == 0) { + img.close(); + img = null; } - return null; + return img; } finally { in.close(); }