From 5cd0a70d0ec8092b8a82e9ce5f01dccba6d4efef Mon Sep 17 00:00:00 2001 From: artdeell Date: Fri, 3 May 2024 21:01:00 +0300 Subject: [PATCH] Feat[download]: don't always redowload files with missing hashes --- .../main/java/net/kdt/pojavlaunch/utils/DownloadUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/DownloadUtils.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/DownloadUtils.java index 367b415d1..b4df71409 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/DownloadUtils.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/DownloadUtils.java @@ -137,7 +137,11 @@ public class DownloadUtils { public static T ensureSha1(File outputFile, @Nullable String sha1, Callable downloadFunction) throws IOException { // Skip if needed - if(sha1 == null) return downloadFile(downloadFunction); + if(sha1 == null) { + // If the file exists and we don't know it's SHA1, don't try to redownload it. + if(outputFile.exists()) return null; + else return downloadFile(downloadFunction); + } int attempts = 0; boolean fileOkay = verifyFile(outputFile, sha1);