From c4c50344fb32c6d56de9af5c1526640bb7c3a4b7 Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 21 May 2019 01:49:27 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8E=20=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20ZIP=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launcher/downloader/ListDownloader.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java b/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java index 7b7fd27d..7646379c 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java @@ -63,7 +63,7 @@ public void download(String base, List applies, Path dstDirFile, D } } public void downloadZip(String base, Path dstDirFile, DownloadCallback callback, DownloadTotalCallback totalCallback) throws IOException, URISyntaxException { - try (CloseableHttpClient httpclient = HttpClients.custom() + /*try (CloseableHttpClient httpclient = HttpClients.custom() .setRedirectStrategy(new LaxRedirectStrategy()) .build()) { HttpGet get; @@ -71,6 +71,17 @@ public void downloadZip(String base, Path dstDirFile, DownloadCallback callback, LogHelper.debug("Download ZIP URL: %s", u.toString()); get = new HttpGet(u); httpclient.execute(get, new FileDownloadResponseHandler(dstDirFile, callback, totalCallback, true)); + }*/ + try (ZipInputStream input = IOHelper.newZipInput(new URL(base))) { + for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) { + if (entry.isDirectory()) + continue; // Skip directories + // Unpack entry + String name = entry.getName(); + LogHelper.subInfo("Downloading file: '%s'", name); + Path fileName = IOHelper.toPath(name); + transfer(input, dstDirFile.resolve(fileName), fileName.toString(), entry.getSize(), callback, totalCallback); + } } }