diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-05-10 02:52:39 +0200 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-05-10 02:52:39 +0200 |
commit | 2e11374529573edd5f67da83082998884fa63b5a (patch) | |
tree | f959770b43f4d075180c072b7243e0b5bec8fe46 /src-tauri/src/northstar/mod.rs | |
parent | 11bd3a3a4f87bedd216bba9b6cb148659d42cf8d (diff) | |
download | FlightCore-2e11374529573edd5f67da83082998884fa63b5a.tar.gz FlightCore-2e11374529573edd5f67da83082998884fa63b5a.zip |
refactor: Move `check_mod_version_number`
to northstar module
Diffstat (limited to 'src-tauri/src/northstar/mod.rs')
-rw-r--r-- | src-tauri/src/northstar/mod.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs index d26ecb64..a969d456 100644 --- a/src-tauri/src/northstar/mod.rs +++ b/src-tauri/src/northstar/mod.rs @@ -1,10 +1,25 @@ //! This module deals with handling things around Northstar such as //! - getting version number -use crate::{check_mod_version_number, constants::CORE_MODS}; +use crate::constants::CORE_MODS; use anyhow::anyhow; use app::{check_origin_running, get_host_os, GameInstall, InstallType}; +/// Check version number of a mod +pub fn check_mod_version_number(path_to_mod_folder: &str) -> Result<String, anyhow::Error> { + let data = std::fs::read_to_string(format!("{path_to_mod_folder}/mod.json"))?; + let parsed_json: serde_json::Value = serde_json::from_str(&data)?; + + let mod_version_number = match parsed_json.get("Version").and_then(|value| value.as_str()) { + Some(version_number) => version_number, + None => return Err(anyhow!("No version number found")), + }; + + log::info!("{}", mod_version_number); + + Ok(mod_version_number.to_string()) +} + /// Returns the current Northstar version number as a string pub fn get_northstar_version_number(game_path: &str) -> Result<String, anyhow::Error> { log::info!("{}", game_path); |