mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Merge branch 'master' into 'master'
Reverted Paths.get in Zip downloader (breaks Android). Forge for Android 1.6.13.002. See merge request core-developers/forge!831
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<packaging.type>jar</packaging.type>
|
||||
<build.min.memory>-Xms128m</build.min.memory>
|
||||
<build.max.memory>-Xmx1024m</build.max.memory>
|
||||
<alpha-version>1.6.13.001</alpha-version>
|
||||
<alpha-version>1.6.13.002</alpha-version>
|
||||
<sign.keystore>keystore</sign.keystore>
|
||||
<sign.alias>alias</sign.alias>
|
||||
<sign.storepass>storepass</sign.storepass>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<packaging.type>jar</packaging.type>
|
||||
<build.min.memory>-Xms128m</build.min.memory>
|
||||
<build.max.memory>-Xmx2048m</build.max.memory>
|
||||
<alpha-version>1.6.13.001</alpha-version>
|
||||
<alpha-version>1.6.13.002</alpha-version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public class Forge implements ApplicationListener {
|
||||
public static final String CURRENT_VERSION = "1.6.13.001";
|
||||
public static final String CURRENT_VERSION = "1.6.13.002";
|
||||
|
||||
private static final ApplicationListener app = new Forge();
|
||||
private static Clipboard clipboard;
|
||||
|
||||
@@ -89,10 +89,10 @@ public class NetDeckCategory extends StorageBase<Deck> {
|
||||
String downloadLoc = c.getFullPath();
|
||||
GuiBase.getInterface().download(new GuiDownloadZipService(c.getName(), "decks", c.getUrl(), downloadLoc, downloadLoc, null) {
|
||||
@Override
|
||||
protected void copyInputStream(InputStream in, File outFile) throws IOException {
|
||||
super.copyInputStream(in, outFile);
|
||||
protected void copyInputStream(InputStream in, String outPath) throws IOException {
|
||||
super.copyInputStream(in, outPath);
|
||||
|
||||
Deck deck = DeckSerializer.fromFile(outFile);
|
||||
Deck deck = DeckSerializer.fromFile(new File(outPath));
|
||||
if (deck != null) {
|
||||
c.map.put(deck.getName(), deck);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -71,10 +70,8 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
||||
public void downloadAndUnzip() {
|
||||
filesExtracted = 0;
|
||||
|
||||
File file = download("temp.zip");
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
String zipFilename = download("temp.zip");
|
||||
if (zipFilename == null) { return; }
|
||||
|
||||
//if assets.zip downloaded successfully, unzip into destination folder
|
||||
try {
|
||||
@@ -87,15 +84,15 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
||||
progressBar.reset();
|
||||
progressBar.setDescription("Deleting old " + desc + "...");
|
||||
if (deleteFolder.equals(destFolder)) { //move zip file to prevent deleting it
|
||||
final File oldFile = file;
|
||||
file = Paths.get(deleteDir.getParentFile().getAbsolutePath(), "temp.zip").toFile();
|
||||
Files.move(oldFile, file);
|
||||
final String oldZipFilename = zipFilename;
|
||||
zipFilename = deleteDir.getParentFile().getAbsolutePath() + File.separator + "temp.zip";
|
||||
Files.move(new File(oldZipFilename), new File(zipFilename));
|
||||
}
|
||||
FileUtil.deleteDirectory(deleteDir);
|
||||
}
|
||||
}
|
||||
|
||||
final ZipFile zipFile = new ZipFile(file);
|
||||
final ZipFile zipFile = new ZipFile(zipFilename);
|
||||
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||
|
||||
progressBar.reset();
|
||||
@@ -113,14 +110,14 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
||||
try {
|
||||
final ZipEntry entry = entries.nextElement();
|
||||
|
||||
final File unzippedEntry = Paths.get(destFolder, entry.getName()).toFile();
|
||||
final String path = destFolder + entry.getName();
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
unzippedEntry.mkdir();
|
||||
new File(path).mkdir();
|
||||
progressBar.setValue(++count);
|
||||
continue;
|
||||
}
|
||||
copyInputStream(zipFile.getInputStream(entry), unzippedEntry);
|
||||
copyInputStream(zipFile.getInputStream(entry), path);
|
||||
progressBar.setValue(++count);
|
||||
filesExtracted++;
|
||||
}
|
||||
@@ -135,7 +132,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
||||
}
|
||||
|
||||
zipFile.close();
|
||||
file.delete();
|
||||
new File(zipFilename).delete();
|
||||
}
|
||||
catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -145,7 +142,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
||||
}
|
||||
}
|
||||
|
||||
public File download(final String filename) {
|
||||
public String download(final String filename) {
|
||||
GuiBase.getInterface().preventSystemSleep(true); //prevent system from going into sleep mode while downloading
|
||||
|
||||
progressBar.reset();
|
||||
@@ -180,7 +177,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
||||
FileUtil.ensureDirectoryExists(destFolder);
|
||||
|
||||
// output stream to write file
|
||||
final File destFile = Paths.get(destFolder, filename).toFile();
|
||||
final String destFile = destFolder + filename;
|
||||
final OutputStream output = new FileOutputStream(destFile);
|
||||
|
||||
int count;
|
||||
@@ -200,7 +197,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
||||
input.close();
|
||||
|
||||
if (cancel) {
|
||||
destFile.delete();
|
||||
new File(destFile).delete();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -215,10 +212,10 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
||||
}
|
||||
}
|
||||
|
||||
protected void copyInputStream(final InputStream in, final File outFile) throws IOException{
|
||||
protected void copyInputStream(final InputStream in, final String outPath) throws IOException{
|
||||
final byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
final BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile));
|
||||
final BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outPath));
|
||||
|
||||
while((len = in.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, len);
|
||||
|
||||
Reference in New Issue
Block a user