Loading src/main/java/ecorp/easy/installer/tasks/DownloadTask.java +27 −31 Original line number Diff line number Diff line Loading @@ -32,9 +32,6 @@ 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 @@ -111,14 +108,17 @@ 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,22 +129,18 @@ public class DownloadTask extends Task<Boolean>{ this.updateTitle("Downloading "+ latestBuildFilename); final String tmpFilePath = localFilePath; final String tmpFilePath = AppConstants.getSourcesFolderPath()+"tmp."+fileName; File lmdFile = new File(AppConstants.getSourcesFolderPath() + "lmd." + fileName); File lmdFile = new File(AppConstants.getSourcesFolderPath()+"lmd."+fileName); //used to Store last modified Date of remote content lmdFile.createNewFile(); if (downloadFile(targetUrl, tmpFilePath, lmdFile)) { logger.debug("Download succeeded. Performing checksum validation."); 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 (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 +27 −31 Original line number Diff line number Diff line Loading @@ -32,9 +32,6 @@ 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 @@ -111,14 +108,17 @@ 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,22 +129,18 @@ public class DownloadTask extends Task<Boolean>{ this.updateTitle("Downloading "+ latestBuildFilename); final String tmpFilePath = localFilePath; final String tmpFilePath = AppConstants.getSourcesFolderPath()+"tmp."+fileName; File lmdFile = new File(AppConstants.getSourcesFolderPath() + "lmd." + fileName); File lmdFile = new File(AppConstants.getSourcesFolderPath()+"lmd."+fileName); //used to Store last modified Date of remote content lmdFile.createNewFile(); if (downloadFile(targetUrl, tmpFilePath, lmdFile)) { logger.debug("Download succeeded. Performing checksum validation."); 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 (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