1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2025-01-08 19:38:58 +01:00

Fix hidden error if request was never even started

If a HTTP request failed to even connect, then the logic determining
whether to retry a partial download would inadvertently throw an error
before it could re-throw the causing error, which resulted in a
confusing error dialog.
This commit is contained in:
Henry Le Grys 2021-05-29 17:38:24 +01:00
parent b7be91bc9c
commit 5b742bc1a1
2 changed files with 10 additions and 1 deletions

View File

@ -269,7 +269,7 @@ public class HttpDownloader implements Downloader {
// We only want to try to resume a partial download if the request succeeded before // We only want to try to resume a partial download if the request succeeded before
// throwing an exception halfway through. If it didn't succeed, just throw the error. // throwing an exception halfway through. If it didn't succeed, just throw the error.
if (tries >= tryCount || !request.isSuccessCode()) { if (tries >= tryCount || !request.isConnected() || !request.isSuccessCode()) {
throw e; throw e;
} }

View File

@ -265,6 +265,15 @@ public class HttpRequest implements Closeable, ProgressObservable {
return inputStream; return inputStream;
} }
/**
* Check if a connection was ever made
*
* @return True if a connection is available, false otherwise
*/
public boolean isConnected() {
return conn != null;
}
/** /**
* Buffer the returned response. * Buffer the returned response.
* *