mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Merge pull request #1251 from kevlahnota/master
fix LibGDXImageFetcher not deleting .tmp files
This commit is contained in:
@@ -155,24 +155,12 @@ public final class ImageKeys {
|
||||
cachedCards.put(filename, file);
|
||||
return file;
|
||||
}
|
||||
// if there's a 1st art variant try with it for .fullborder images
|
||||
file = findFile(dir, fullborderFile.replaceAll("[0-9]*.fullborder", "1.fullborder"));
|
||||
if (file != null) {
|
||||
cachedCards.put(filename, file);
|
||||
return file;
|
||||
}
|
||||
// if there's an art variant try without it for .full images
|
||||
file = findFile(dir, filename.replaceAll("[0-9].full",".full"));
|
||||
if (file != null) {
|
||||
cachedCards.put(filename, file);
|
||||
return file;
|
||||
}
|
||||
// if there's a 1st art variant try with it for .full images
|
||||
file = findFile(dir, filename.replaceAll("[0-9]*.full", "1.full"));
|
||||
if (file != null) {
|
||||
cachedCards.put(filename, file);
|
||||
return file;
|
||||
}
|
||||
//setlookup
|
||||
if (hasSetLookup(filename)) {
|
||||
toFind.add(filename);
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.util;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
@@ -42,9 +43,11 @@ public class LibGDXImageFetcher extends ImageFetcher {
|
||||
FileHandle destFile = new FileHandle(newdespath + ".tmp");
|
||||
System.out.println(newdespath);
|
||||
destFile.parent().mkdirs();
|
||||
|
||||
OutputStream out = new FileOutputStream(destFile.file());
|
||||
// Conversion to JPEG will be handled differently depending on the platform
|
||||
Forge.getDeviceAdapter().convertToJPEG(is, new FileOutputStream(destFile.file()));
|
||||
Forge.getDeviceAdapter().convertToJPEG(is, out);
|
||||
is.close();
|
||||
out.close(); //close outputstream before destfile.moveto so it can delete the tmp file internally
|
||||
destFile.moveTo(new FileHandle(newdespath));
|
||||
|
||||
System.out.println("Saved image to " + newdespath);
|
||||
|
||||
Reference in New Issue
Block a user