From 31c32aa2c2ca04a6f2f27e8a4c596cc2a0eeb8be Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sat, 16 Nov 2019 20:38:59 +0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A0=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20url=20=D0=B8=20=D0=BF=D1=83=D1=82?= =?UTF-8?q?=D0=B8=20=D0=B2=20ListDownloader.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/downloader/ListDownloader.java | 16 +++++++++++++--- modules | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java b/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java index 643e50e3..741cdf3f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java @@ -47,10 +47,18 @@ public interface DownloadTotalCallback { public static class DownloadTask { public final String apply; - public final long size; + public long size; + public final String urlApply; public DownloadTask(String apply, long size) { this.apply = apply; + urlApply = apply; + this.size = size; + } + + public DownloadTask(String urlApply, String apply, long size) { + this.apply = apply; + this.urlApply = urlApply; this.size = size; } } @@ -70,7 +78,7 @@ public void download(String base, List applies, Path dstDirFile, D String path = baseUri.getPath(); List excs = new CopyOnWriteArrayList<>(); for (DownloadTask apply : applies) { - URI u = new URI(scheme, host, path + apply.apply, "", ""); + URI u = new URI(scheme, host, path + apply.urlApply, "", ""); callback.stateChanged(apply.apply, 0L, apply.size); Path targetPath = dstDirFile.resolve(apply.apply); toExec.add(() -> { @@ -181,7 +189,9 @@ public Path handleResponse(HttpResponse response) throws IOException { } long contentLength = response.getEntity().getContentLength(); if (task != null && contentLength != task.size) { - LogHelper.warning("Missing content length: expected %d | found %d", task.size, contentLength); + if (task.size > 0) + LogHelper.warning("Missing content length: expected %d | found %d", task.size, contentLength); + else task.size = contentLength; } if (zip) { try (ZipInputStream input = IOHelper.newZipInput(source)) { diff --git a/modules b/modules index 52818e6e..e098678d 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 52818e6ef05d90ad678d02e83f9bd4140d8eda34 +Subproject commit e098678d7ea2c5e6a926f457dcbc820c4e9fba66