X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=library%2FWebLibrary.java;h=7381ae368661023aa3ac2a23c643d6f4461ac658;hb=379a497e6fd2b959c57b2ff4023413e2daf36232;hp=978dd9af51c05e5b56f93c2d61948e34fcbcc968;hpb=cd1aa392a6e17382f573ee816c26fd5f19301f02;p=fanfix.git diff --git a/library/WebLibrary.java b/library/WebLibrary.java index 978dd9a..7381ae3 100644 --- a/library/WebLibrary.java +++ b/library/WebLibrary.java @@ -126,6 +126,26 @@ public class WebLibrary extends BasicLibrary { return new Version(); } + /** + * Stop the server. + * + * @throws IOException + * in case of I/O errors + */ + public void stop() throws IOException { + 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 public Status getStatus() { try { @@ -153,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(); } @@ -168,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(); } @@ -183,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(); } @@ -309,6 +332,9 @@ public class WebLibrary extends BasicLibrary { try { subPg = JsonIO.toProgress( new JSONObject(IOUtils.readSmallStream(in))); + pg.setName(subPg.getName()); + pg.setMinMax(subPg.getMin(), subPg.getMax()); + pg.setProgress(subPg.getProgress()); } catch (Exception e) { subPg = null; } finally {