Minor cleanup/optimisations to downloading, should help a little bit more with asset downloading.

Closes #359
This commit is contained in:
modmuss50
2021-03-04 23:50:02 +00:00
parent d02055eb23
commit 679026ef31
5 changed files with 48 additions and 38 deletions

View File

@@ -89,6 +89,7 @@ public class DownloadUtil {
if ((code < 200 || code > 299) && code != HttpURLConnection.HTTP_NOT_MODIFIED) {
//Didn't get what we expected
delete(to);
throw new IOException(connection.getResponseMessage() + " for " + from);
}
@@ -111,7 +112,7 @@ public class DownloadUtil {
try { // Try download to the output
FileUtils.copyInputStreamToFile(connection.getInputStream(), to);
} catch (IOException e) {
to.delete(); // Probably isn't good if it fails to copy/save
delete(to); // Probably isn't good if it fails to copy/save
throw e;
}