Loading src/main/java/ecorp/easy/installer/tasks/DownloadTask.java +31 −27 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.DecimalFormat; Loading Loading @@ -108,17 +111,14 @@ public class DownloadTask extends Task<Boolean>{ this.updateTitle("Downloading " + latestBuildFilename + checkSumExtension); File checksumLmdFile = new File(AppConstants.getSourcesFolderPath() + "lmd." + fileName + checkSumExtension); checksumLmdFile.createNewFile(); // Download checksum. If file not downloaded return false and stop downloadin because integrity isn't guaranteed if (!downloadFile(targetUrl + checkSumExtension, checksumFilePath, checksumLmdFile)) { updateMessage(i18n.getString("download_lbl_cantcheckIntegrity")); return false; } //If checksum valid it means that file is already there and up to date updateMessage(i18n.getString("download_lbl_checkingIntegrity")); if (validChecksum(checksumFilePath)) { updateMessage(i18n.getString("download_lbl_fileAlreadyUptoDate")); Loading @@ -129,18 +129,22 @@ public class DownloadTask extends Task<Boolean>{ this.updateTitle("Downloading " + latestBuildFilename); final String tmpFilePath = AppConstants.getSourcesFolderPath()+"tmp."+fileName; final String tmpFilePath = localFilePath; File lmdFile = new File(AppConstants.getSourcesFolderPath()+"lmd."+fileName); //used to Store last modified Date of remote content File lmdFile = new File(AppConstants.getSourcesFolderPath() + "lmd." + fileName); lmdFile.createNewFile(); if ( downloadFile(targetUrl, tmpFilePath, lmdFile) )//Download file { logger.debug("Downloaded succeed. Rename temp file to right fileName"); File tmpFile = new File(tmpFilePath); tmpFile.renameTo(new File(localFilePath)); return validChecksum(checksumFilePath); if (downloadFile(targetUrl, tmpFilePath, lmdFile)) { logger.debug("Download succeeded. Performing checksum validation."); if (validChecksum(checksumFilePath)) { return true; // Download successful and checksum validated } else { updateMessage(i18n.getString("download_lbl_invalidChecksum")); // Delete the downloaded file as checksum validation failed Files.deleteIfExists(Paths.get(localFilePath)); return false; } } else { updateMessage(i18n.getString("download_lbl_downloadError")); return false; Loading Loading
src/main/java/ecorp/easy/installer/tasks/DownloadTask.java +31 −27 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.DecimalFormat; Loading Loading @@ -108,17 +111,14 @@ public class DownloadTask extends Task<Boolean>{ this.updateTitle("Downloading " + latestBuildFilename + checkSumExtension); File checksumLmdFile = new File(AppConstants.getSourcesFolderPath() + "lmd." + fileName + checkSumExtension); checksumLmdFile.createNewFile(); // Download checksum. If file not downloaded return false and stop downloadin because integrity isn't guaranteed if (!downloadFile(targetUrl + checkSumExtension, checksumFilePath, checksumLmdFile)) { updateMessage(i18n.getString("download_lbl_cantcheckIntegrity")); return false; } //If checksum valid it means that file is already there and up to date updateMessage(i18n.getString("download_lbl_checkingIntegrity")); if (validChecksum(checksumFilePath)) { updateMessage(i18n.getString("download_lbl_fileAlreadyUptoDate")); Loading @@ -129,18 +129,22 @@ public class DownloadTask extends Task<Boolean>{ this.updateTitle("Downloading " + latestBuildFilename); final String tmpFilePath = AppConstants.getSourcesFolderPath()+"tmp."+fileName; final String tmpFilePath = localFilePath; File lmdFile = new File(AppConstants.getSourcesFolderPath()+"lmd."+fileName); //used to Store last modified Date of remote content File lmdFile = new File(AppConstants.getSourcesFolderPath() + "lmd." + fileName); lmdFile.createNewFile(); if ( downloadFile(targetUrl, tmpFilePath, lmdFile) )//Download file { logger.debug("Downloaded succeed. Rename temp file to right fileName"); File tmpFile = new File(tmpFilePath); tmpFile.renameTo(new File(localFilePath)); return validChecksum(checksumFilePath); if (downloadFile(targetUrl, tmpFilePath, lmdFile)) { logger.debug("Download succeeded. Performing checksum validation."); if (validChecksum(checksumFilePath)) { return true; // Download successful and checksum validated } else { updateMessage(i18n.getString("download_lbl_invalidChecksum")); // Delete the downloaded file as checksum validation failed Files.deleteIfExists(Paths.get(localFilePath)); return false; } } else { updateMessage(i18n.getString("download_lbl_downloadError")); return false; Loading