Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 8ba0611b authored by Ahmed Harhash's avatar Ahmed Harhash
Browse files

Revert "easy-installer: Implement Direct Post-Download Integrity Check in DownloadTask"

This reverts commit 3975f8b0.
parent fdfa2c81
Loading
Loading
Loading
Loading
+27 −31
Original line number Diff line number Diff line
@@ -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;
@@ -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"));
@@ -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;