blob: 14c37ecce490444aa9e4f0dbebd7380975b244a2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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<dyn std::error::Error>> {
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<String> = 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(())
}
|