diff --git a/common/src/main/java/de/rafael/modflared/binary/download/DownloadedCloudflared.java b/common/src/main/java/de/rafael/modflared/binary/download/DownloadedCloudflared.java index a248838..7d93061 100644 --- a/common/src/main/java/de/rafael/modflared/binary/download/DownloadedCloudflared.java +++ b/common/src/main/java/de/rafael/modflared/binary/download/DownloadedCloudflared.java @@ -117,21 +117,22 @@ public CompletableFuture> isUptoDate() { for (int i = 0; i < 4; i++) { Modflared.LOGGER.info("Downloading cloudflared version {} from github. Attempt: {}", version, i + 1); var downloadedFile = syncDownloadFile(); + Modflared.LOGGER.info("Downloaded file preparing cloudflared binary..."); var file = new File(TunnelManager.DATA_FOLDER, download.fileName()); + prepareFile(downloadedFile, file); + // Check if file is corrupt Modflared.LOGGER.info("Checking file integrity"); - var provided = GithubAPI.FileHash.computeHash(downloadedFile); + var provided = GithubAPI.FileHash.computeHash(file); if(expected.compareTo(provided)) { Modflared.LOGGER.info("Download finished of cloudflared version {}!", version); - Modflared.LOGGER.info("Downloaded file preparing cloudflared binary..."); - prepareFile(downloadedFile, file); return; } else { Modflared.LOGGER.warn("This downloaded file does not match with the file hash provided on GitHub."); Modflared.LOGGER.warn("Expected {}, Provided: {}", expected.hash(), provided.hash()); - downloadedFile.delete(); - } + file.delete(); + } } } catch (InterruptedException exception) { throw new IllegalStateException("Error while unpacking MacOS cloudflared download", exception);