diff --git a/forge-gui-android/pom.xml b/forge-gui-android/pom.xml index f0fa2395de1..53850f2ecef 100644 --- a/forge-gui-android/pom.xml +++ b/forge-gui-android/pom.xml @@ -7,7 +7,7 @@ jar -Xms128m -Xmx1024m - 1.5.34.003 + 1.5.34.004 diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index 1edba8d93a7..b81f222be98 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -38,7 +38,7 @@ import forge.util.FileUtil; import forge.util.Utils; public class Forge implements ApplicationListener { - public static final String CURRENT_VERSION = "1.5.34.003"; + public static final String CURRENT_VERSION = "1.5.34.004"; private static final ApplicationListener app = new Forge(); private static Clipboard clipboard; diff --git a/forge-gui/src/main/java/forge/download/GuiDownloadZipService.java b/forge-gui/src/main/java/forge/download/GuiDownloadZipService.java index 4101888a1b8..7e61134b62c 100644 --- a/forge-gui/src/main/java/forge/download/GuiDownloadZipService.java +++ b/forge-gui/src/main/java/forge/download/GuiDownloadZipService.java @@ -9,7 +9,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; -import java.nio.charset.Charset; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @@ -25,7 +24,7 @@ import forge.util.FileUtil; public class GuiDownloadZipService extends GuiDownloadService { private final String name, desc, sourceUrl, destFolder, deleteFolder; - private int filesDownloaded; + private int filesExtracted; public GuiDownloadZipService(String name0, String desc0, String sourceUrl0, String destFolder0, String deleteFolder0, IProgressBar progressBar0) { name = name0; @@ -60,7 +59,7 @@ public class GuiDownloadZipService extends GuiDownloadService { FThreads.invokeInEdtNowOrLater(new Runnable() { @Override public void run() { - progressBar.setDescription(filesDownloaded + " " + desc + " downloaded"); + progressBar.setDescription(filesExtracted + " " + desc + " extracted"); finish(); } }); @@ -68,7 +67,7 @@ public class GuiDownloadZipService extends GuiDownloadService { } public void downloadAndUnzip() { - filesDownloaded = 0; + filesExtracted = 0; String zipFilename = download("temp.zip"); if (zipFilename == null) { return; } @@ -89,7 +88,7 @@ public class GuiDownloadZipService extends GuiDownloadService { } } - ZipFile zipFile = new ZipFile(zipFilename, Charset.forName("CP866")); //ensure unzip doesn't fail due to non UTF-8 chars + ZipFile zipFile = new ZipFile(zipFilename); Enumeration entries = zipFile.entries(); progressBar.reset(); @@ -100,20 +99,31 @@ public class GuiDownloadZipService extends GuiDownloadService { FileUtil.ensureDirectoryExists(destFolder); int count = 0; + int failedCount = 0; while (entries.hasMoreElements()) { if (cancel) { break; } - ZipEntry entry = (ZipEntry)entries.nextElement(); + try { + ZipEntry entry = (ZipEntry)entries.nextElement(); - String path = destFolder + entry.getName(); - if (entry.isDirectory()) { - new File(path).mkdir(); + String path = destFolder + entry.getName(); + if (entry.isDirectory()) { + new File(path).mkdir(); + progressBar.setValue(++count); + continue; + } + copyInputStream(zipFile.getInputStream(entry), path); progressBar.setValue(++count); - continue; + filesExtracted++; } - copyInputStream(zipFile.getInputStream(entry), path); - progressBar.setValue(++count); - filesDownloaded++; + catch (Exception e) { //don't quit out completely if an entry is not UTF-8 + progressBar.setValue(++count); + failedCount++; + } + } + + if (failedCount > 0) { + Log.error("Downloading " + desc, failedCount + " " + desc + " could not be extracted"); } zipFile.close();