import java.io.IOException;
import java.io.OutputStreamWriter;
-import javax.imageio.ImageIO;
-
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.bundles.Config;
import be.nikiroo.fanfix.data.MetaData;
public static void writeInfo(File targetDir, String targetName,
MetaData meta) throws IOException {
File info = new File(targetDir, targetName + ".info");
- BufferedWriter infoWriter = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(info), "UTF-8"));
- if (meta != null) {
- try {
+ BufferedWriter infoWriter = null;
+ try {
+ infoWriter = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(info), "UTF-8"));
+
+ if (meta != null) {
String tags = "";
if (meta.getTags() != null) {
for (String tag : meta.getTags()) {
writeMeta(infoWriter, "CREATION_DATE", meta.getCreationDate());
writeMeta(infoWriter, "FAKE_COVER",
Boolean.toString(meta.isFakeCover()));
- } finally {
+ }
+ } finally {
+ if (infoWriter != null) {
infoWriter.close();
}
}
MetaData meta) {
if (meta != null && meta.getCover() != null) {
try {
- String format = Instance.getConfig()
- .getString(Config.IMAGE_FORMAT_COVER).toLowerCase();
- ImageIO.write(meta.getCover(), format, new File(targetDir,
- targetName + "." + format));
+ Instance.getCache().saveAsImage(meta.getCover(),
+ new File(targetDir, targetName), true);
} catch (IOException e) {
// Allow to continue without cover
- Instance.syserr(new IOException(
- "Failed to save the cover image", e));
+ Instance.getTraceHandler().error(
+ new IOException("Failed to save the cover image", e));
}
}
}