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

Verified Commit 8d748322 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Update checksum check to handle only the sha

parent 12887c9f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ public class DownloadTask extends Task<Boolean>{

        //If checksum valid it means that file is already there and up to date
        updateMessage(i18n.getString("download_lbl_checkingIntegrity")); 
        if ( validChecksum(checksumFilePath) ){
        if ( validChecksum(localFilePath, checksumFilePath) ){
            updateMessage(i18n.getString("download_lbl_fileAlreadyUptoDate"));
            return true;
        }
@@ -137,7 +137,7 @@ public class DownloadTask extends Task<Boolean>{
            logger.debug("Downloaded succeed. Rename temp file to right fileName");
            File tmpFile = new File(tmpFilePath);
            tmpFile.renameTo(new File(localFilePath));
            return validChecksum(checksumFilePath);
            return validChecksum(localFilePath, checksumFilePath);

        }else{
            updateMessage(i18n.getString("download_lbl_downloadError"));
@@ -340,7 +340,7 @@ public class DownloadTask extends Task<Boolean>{
     * @throws NoSuchAlgorithmException
     * @throws IOException 
     */
    private boolean validChecksum( String checksumFilePath) throws NoSuchAlgorithmException, IOException{
    private boolean validChecksum(String localFilePath, String checksumFilePath) throws NoSuchAlgorithmException, IOException{
        logger.debug("validChecksum("+checksumFilePath+")");
        //get file containing checksum
        File checksumFile = new File(checksumFilePath);
@@ -356,7 +356,7 @@ public class DownloadTask extends Task<Boolean>{
        String[] splittedLine = checksumLine.split("\\s+"); //@todo use pattern & matcher

        //check local file exist
        File file = new File(AppConstants.getSourcesFolderPath()+splittedLine[1]);
        File file = new File(localFilePath);
        if(!file.exists()){         //if file concerned by checksum doesn't exist we can't validate
            updateMessage(i18n.getString("download_lbl_localFileNotFound")); //@todo not sure it is required...
            logger.debug("  "+splittedLine[1]+" do not exists");