weblib: fix cover image close()d
[fanfix.git] / src / be / nikiroo / fanfix / library / WebLibrary.java
index 0f2510dd544218279d8ddcaa1beae3ad097d631c..7381ae368661023aa3ac2a23c643d6f4461ac658 100644 (file)
@@ -173,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();
                }
@@ -188,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();
                }
@@ -203,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();
                }