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];
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();
}
}
* 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) {