Skip to content
Snippets Groups Projects
Commit 69afd529 authored by Cgarcia's avatar Cgarcia
Browse files

improve the engines download

parent 23268588
No related branches found
No related tags found
No related merge requests found
......@@ -253,7 +253,6 @@ public class DeepLearningVersionDownloader
private static Path downloadFile(String urlString, Path targetDirectory, ProgressListener progressListener)
throws IOException
{
URL url = new URL(urlString);
Path localFilePath = toLocalVersionFile(targetDirectory, urlString);
Files.deleteIfExists(localFilePath);
......@@ -261,8 +260,16 @@ public class DeepLearningVersionDownloader
try
{
HttpURLConnection httpConnection = (HttpURLConnection) (url.openConnection());
long completeFileSize = httpConnection.getContentLength();
while (httpConnection.getResponseCode() == 302) {
url = new URL(httpConnection.getHeaderField("Location"));
httpConnection = (HttpURLConnection) (url.openConnection());
}
long completeFileSize = httpConnection.getContentLengthLong();
if (completeFileSize == -1) {
progressListener.notifyProgress(1, 1);
return downloadFile(urlString, targetDirectory);
}
completeFileSize = 1;
try (BufferedInputStream in = new BufferedInputStream(httpConnection.getInputStream()))
{
FileOutputStream fos = new FileOutputStream(localFilePath.toFile());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment