From 7b695e77adf9e3f2a38b02ffebe6609f42652270 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 3 Apr 2019 23:20:38 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20LauncherRequ?= =?UTF-8?q?est?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launcher/downloader/ListDownloader.java | 12 ++++-------- .../launcher/request/update/LauncherRequest.java | 8 +++++--- 2 files changed, 9 insertions(+), 11 deletions(-) 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 56293bd2..952e22cb 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java @@ -38,21 +38,17 @@ public void download(String base, List applies, Path dstDirFile) throws } } - public static void downloadOne(String url, Path target) throws IOException, URISyntaxException + public void downloadOne(String url, Path target) throws IOException, URISyntaxException { try (CloseableHttpClient httpclient = HttpClients.custom() .setRedirectStrategy(new LaxRedirectStrategy()) .build()) { - HttpGet get = null; + HttpGet get; URI u = new URL(url).toURI(); LogHelper.debug("Download URL: %s", u.toString()); - if (get == null) get = new HttpGet(u); - else { - get.reset(); - get.setURI(u); - } - httpclient.execute(get, new FileDownloadResponseHandler(target)); + get = new HttpGet(u); + httpclient.execute(get, new FileDownloadResponseHandler(target.toAbsolutePath())); } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java index 52113387..d0933d36 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java @@ -56,9 +56,11 @@ public static void update(LauncherConfig config, LauncherRequestEvent result) th IOHelper.transfer(BINARY_PATH, stream); }*/ try { - ListDownloader.downloadOne(result.url, BINARY_PATH); - } catch (URISyntaxException e) { - throw new SecurityException(e); + ListDownloader downloader = new ListDownloader(); + downloader.downloadOne(result.url, BINARY_PATH); + } catch(Throwable e) + { + LogHelper.error(e); } } builder.start();