X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FLocalLibrary.java;h=11c36630adcef96ea73d17c8712d84495260299a;hp=f9350efc4b353abc92bb9849ec8aac21368493a5;hb=085a2f9a3a811a910de7c3011eb6f5ef2ab18aa0;hpb=2249988a85d0daeb952b4d2df63b838c9385143c diff --git a/src/be/nikiroo/fanfix/library/LocalLibrary.java b/src/be/nikiroo/fanfix/library/LocalLibrary.java index f9350ef..11c3663 100644 --- a/src/be/nikiroo/fanfix/library/LocalLibrary.java +++ b/src/be/nikiroo/fanfix/library/LocalLibrary.java @@ -331,14 +331,14 @@ public class LocalLibrary extends BasicLibrary { * The directory (full path) where the new {@link Story} related to this * {@link MetaData} should be located on disk. * - * @param type + * @param source * the type (source) * * @return the target directory */ - private File getExpectedDir(String type) { - String source = type.replaceAll("[^a-zA-Z0-9._+-]", "_"); - return new File(baseDir, source); + private File getExpectedDir(String source) { + String sanitizedSource = source.replaceAll("[^a-zA-Z0-9._+-]", "_"); + return new File(baseDir, sanitizedSource); } /** @@ -501,4 +501,23 @@ public class LocalLibrary extends BasicLibrary { return stories; } + + /** + * Fix the source cover to the given story cover. + * + * @param source + * the source to change + * @param coverImage + * the cover image + */ + void setSourceCover(String source, BufferedImage coverImage) { + sourceCovers.put(source, coverImage); + File cover = new File(getExpectedDir(source), ".cover.png"); + try { + ImageIO.write(sourceCovers.get(source), "png", cover); + } catch (IOException e) { + Instance.syserr(e); + sourceCovers.remove(source); + } + } }