TODO this should at somepoint be changed to `-> Result , ModLoaderError>` to properly convey that some things might critically fail.
(
mod_files: &Vec<FileToProcess>,
data: &Arc<Mutex<ModLoaderAppData>>,
set_enabled: bool,
)
| 18 | // TODO this should at somepoint be changed to `-> Result<Vec<ModLoaderWarning>, ModLoaderError>` |
| 19 | // to properly convey that some things might critically fail. |
| 20 | pub(crate) fn process_modfiles( |
| 21 | mod_files: &Vec<FileToProcess>, |
| 22 | data: &Arc<Mutex<ModLoaderAppData>>, |
| 23 | set_enabled: bool, |
| 24 | ) -> Vec<ModLoaderWarning> { |
| 25 | debug!("Processing mod files: {:?}", mod_files); |
| 26 | |
| 27 | let mut warnings = Vec::new(); |
| 28 | |
| 29 | // read metadata from pak files and collect for each mod_id |
| 30 | let (mods_read, read_warnings) = read_pak_files(mod_files); |
| 31 | warnings.extend(read_warnings); |
| 32 | |
| 33 | let mut data_guard = data.lock(); |
| 34 | let filter: Vec<String> = mods_read.keys().cloned().collect(); |
| 35 | |
| 36 | // turn metadata into proper data structures |
| 37 | insert_mods_from_readdata(&mods_read, &mut data_guard, set_enabled); |
| 38 | |
| 39 | // pick version |
| 40 | auto_pick_versions(&mut data_guard); |
| 41 | |
| 42 | // set top level data |
| 43 | set_mod_data_from_version(&mut data_guard, &filter); |
| 44 | |
| 45 | // fetch index files |
| 46 | |
| 47 | // gather index files from all the mods |
| 48 | let index_files_info = gather_index_files(&data_guard, &filter); |
| 49 | |
| 50 | // drop guard to allow UI to render while index files are being downloaded |
| 51 | drop(data_guard); |
| 52 | |
| 53 | // actually download index files |
| 54 | let (index_files, index_file_warnings) = download_index_files(index_files_info); |
| 55 | warnings.extend(index_file_warnings); |
| 56 | |
| 57 | let mut data_guard = data.lock(); |
| 58 | |
| 59 | // insert index file data into the mod data |
| 60 | let insert_warnings = insert_index_file_data(&index_files, &mut data_guard); |
| 61 | warnings.extend(insert_warnings); |
| 62 | |
| 63 | warnings |
| 64 | } |
no test coverage detected