use std::io::{Error, ErrorKind}; use crate::{config::Cfg, modrinth::projects, get_current_list, db::{get_mods_from_list, get_versions}}; pub async fn update(config: Cfg) -> Result<(), Box> { let current_list = get_current_list(config.clone())?; let mods = get_mods_from_list(config.clone(), current_list)?; let mut projects = projects(String::from(&config.apis.modrinth), mods.clone()).await; let mut versions = get_versions(config, mods)?; projects.sort_by_key(|p| p.id.clone()); versions.sort_by_key(|v| v.mod_id.clone()); let mut update_stack: Vec = vec![]; for (index, project) in projects.iter().enumerate() { let cmp_version = &versions[index]; let p_id = &project.id; let v_id = &cmp_version.mod_id; if p_id != v_id { return Err(Box::new(Error::new(ErrorKind::Other, "COMPARE_SORTING_ERR"))); }; println!("{}:{}", p_id, v_id); if project.versions.join("|") != cmp_version.versions { update_stack.push(String::from(&project.id)); }; }; //TODO UPDATE dbg!(update_stack); Ok(()) }