mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
ensure closing of fileoutputstream in ScryfallSymbolsSource
This commit is contained in:
parent
9402c4a59c
commit
1e18875725
1 changed files with 5 additions and 3 deletions
|
@ -9,6 +9,7 @@ import java.util.*;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import mage.util.StreamUtils;
|
||||
import org.mage.plugins.card.dl.DownloadJob;
|
||||
|
||||
import static org.mage.card.arcane.ManaSymbols.getSymbolFileNameAsSVG;
|
||||
|
@ -106,20 +107,21 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
|||
if (destFile.exists() && (destFile.length() > 0)){
|
||||
continue;
|
||||
}
|
||||
|
||||
FileOutputStream stream = null;
|
||||
try {
|
||||
// base64 transform
|
||||
String data64 = foundedData.get(searchCode);
|
||||
Base64.Decoder dec = Base64.getDecoder();
|
||||
byte[] fileData = dec.decode(data64);
|
||||
|
||||
FileOutputStream stream = new FileOutputStream(destFile);
|
||||
stream = new FileOutputStream(destFile);
|
||||
stream.write(fileData);
|
||||
stream.close();
|
||||
|
||||
LOGGER.info("New svg symbol downloaded: " + needCode);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Can't decode svg icon and save to file: " + destFile.getPath() + ", reason: " + e.getMessage());
|
||||
} finally {
|
||||
StreamUtils.closeQuietly(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue