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

Commit 756f7867 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

update ConfigParser.parseSourceToDownload() to use new RomSource class

parent 834e1caa
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package ecorp.easy.installer.utils;

import ecorp.easy.installer.AppConstants;
import ecorp.easy.installer.models.Command;
import ecorp.easy.installer.models.RomSource;
import ecorp.easy.installer.models.steps.BasicStep;
import ecorp.easy.installer.models.steps.CustomExecutableStep;
import ecorp.easy.installer.models.steps.CustomStep;
@@ -232,24 +233,28 @@ public class ConfigParser {
    /**
     * Parse Sources To Download from Yaml file
     * @param yaml data load from Yaml
     * @return HashMap containing sources's URL & local path to store
     * @return HashMap<String, RomSource> containing sources's URL & local path to store associated to a key
     * @throws java.text.ParseException
     */
    public static HashMap<String, String> parseSourcesToDownload(HashMap yaml) throws ParseException, ClassCastException{
    public static HashMap<String, RomSource> parseSourcesToDownload(HashMap yaml) throws ParseException, ClassCastException{
        logger.info("parseSourcesToDownload(...yaml...)");
        
        HashMap<String, String> result = new HashMap<>();
        HashMap<String, RomSource> result = new HashMap<>();
        
        for(String key : (Set<String>) yaml.keySet() ){

            Map source = (Map) yaml.get(key);
            //@TODO Would be better to put below tests elsewhere
            if(key.equals("rom")){
                AppConstants.setEArchivePath((String) source.get("filePath"));
            }
            if(key.equals("twrp")){
                AppConstants.setTwrpImgPath((String) source.get("filePath"));
            }
            
            logger.debug("--> url: {}, filePath: {}", source.get("url"), source.get("filePath"));
            result.put((String) source.get("url"), (String) source.get("filePath"));
            final RomSource currentSource = new RomSource((String) source.get("url"), (String) source.get("filePath"));
            result.put(key, currentSource );
        }
        return result;
    }