mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Фикс LauncherRequest
This commit is contained in:
parent
468ff01f9f
commit
04cdfcb360
2 changed files with 28 additions and 4 deletions
|
@ -37,6 +37,25 @@ public void download(String base, List<String> applies, Path dstDirFile) throws
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void downloadOne(String url, Path target) throws IOException, URISyntaxException
|
||||||
|
{
|
||||||
|
try (CloseableHttpClient httpclient = HttpClients.custom()
|
||||||
|
.setRedirectStrategy(new LaxRedirectStrategy())
|
||||||
|
.build()) {
|
||||||
|
|
||||||
|
HttpGet get = null;
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String escapeURL(String apply)
|
public String escapeURL(String apply)
|
||||||
{
|
{
|
||||||
return apply.replaceAll(" ", "%20");
|
return apply.replaceAll(" ", "%20");
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import ru.gravit.launcher.LauncherAPI;
|
import ru.gravit.launcher.LauncherAPI;
|
||||||
import ru.gravit.launcher.LauncherConfig;
|
import ru.gravit.launcher.LauncherConfig;
|
||||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||||
|
import ru.gravit.launcher.downloader.ListDownloader;
|
||||||
import ru.gravit.launcher.events.request.LauncherRequestEvent;
|
import ru.gravit.launcher.events.request.LauncherRequestEvent;
|
||||||
import ru.gravit.launcher.request.Request;
|
import ru.gravit.launcher.request.Request;
|
||||||
import ru.gravit.launcher.request.RequestType;
|
import ru.gravit.launcher.request.RequestType;
|
||||||
|
@ -17,9 +18,7 @@
|
||||||
import ru.gravit.utils.helper.SecurityHelper;
|
import ru.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -50,10 +49,16 @@ public static void update(LauncherConfig config, LauncherRequestEvent result) th
|
||||||
if (result.binary != null)
|
if (result.binary != null)
|
||||||
IOHelper.write(BINARY_PATH, result.binary);
|
IOHelper.write(BINARY_PATH, result.binary);
|
||||||
else {
|
else {
|
||||||
URLConnection connection = IOHelper.newConnection(new URL(result.url));
|
/*URLConnection connection = IOHelper.newConnection(new URL(result.url));
|
||||||
|
connection.setDoOutput(true);
|
||||||
connection.connect();
|
connection.connect();
|
||||||
try (OutputStream stream = connection.getOutputStream()) {
|
try (OutputStream stream = connection.getOutputStream()) {
|
||||||
IOHelper.transfer(BINARY_PATH, stream);
|
IOHelper.transfer(BINARY_PATH, stream);
|
||||||
|
}*/
|
||||||
|
try {
|
||||||
|
ListDownloader.downloadOne(result.url, BINARY_PATH);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builder.start();
|
builder.start();
|
||||||
|
|
Loading…
Reference in a new issue