From 0b0118446fd519cf5d77ee8fca17b48bfcb26f56 Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Thu, 20 Feb 2020 14:35:10 +0800 Subject: [PATCH] fix: download empty file from MCBBS --- .../main/java/org/jackhuang/hmcl/task/FileDownloadTask.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/task/FileDownloadTask.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/task/FileDownloadTask.java index 14ce4a34f..7c0edcbf6 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/task/FileDownloadTask.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/task/FileDownloadTask.java @@ -234,6 +234,10 @@ public class FileDownloadTask extends Task { } catch (IOException e) { Logging.LOG.log(Level.WARNING, "Unable to use cached file, redownload it", e); repository.removeRemoteEntry(con); + // Now we must reconnect the server since 304 may result in empty content, + // if we want to redownload the file, we must reconnect the server without etag settings. + repeat--; + continue; } } else if (con.getResponseCode() / 100 != 2) { throw new ResponseCodeException(url, con.getResponseCode());