diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2023-05-17 16:47:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 16:47:00 +0200 |
commit | 76f621a8454389ffbe1a6fe7fada0deeebf2f757 (patch) | |
tree | a3f57d757e87765e0511607cdf2f55819bee7a2f /src-tauri | |
parent | 9746cdeb47b226087ced574cddaac829b995e79b (diff) | |
download | FlightCore-76f621a8454389ffbe1a6fe7fada0deeebf2f757.tar.gz FlightCore-76f621a8454389ffbe1a6fe7fada0deeebf2f757.zip |
feat: Better logging regarding mod installation (#363)
* fix: Make log comment more specific
* feat: Log attempting to create temp dir
* feat: Log mod to install and GameInstall struct
* refactor: Replace `dbg` with proper logging
* refactor: Replace `dbg` with proper logging
* feat: Warning log mod install error
* style: Fix formatting
* feat: Log libthermite error and modstring
when mod install fails
Diffstat (limited to 'src-tauri')
-rw-r--r-- | src-tauri/src/main.rs | 10 | ||||
-rw-r--r-- | src-tauri/src/mod_management/mod.rs | 10 | ||||
-rw-r--r-- | src-tauri/src/northstar/install.rs | 4 |
3 files changed, 19 insertions, 5 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 5675a0df..b27233b7 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -308,7 +308,7 @@ async fn install_northstar_caller( northstar_package_name: Option<String>, version_number: Option<String>, ) -> Result<bool, String> { - log::info!("Running"); + log::info!("Running Northstar install"); // Get Northstar package name (`Northstar` vs `NorthstarReleaseCandidate`) let northstar_package_name = northstar_package_name @@ -356,7 +356,13 @@ async fn install_mod_caller( game_install: GameInstall, thunderstore_mod_string: String, ) -> Result<(), String> { - fc_download_mod_and_install(&game_install, &thunderstore_mod_string).await?; + match fc_download_mod_and_install(&game_install, &thunderstore_mod_string).await { + Ok(()) => (), + Err(err) => { + log::warn!("{err}"); + return Err(err); + } + }; match clean_up_download_folder(&game_install, false) { Ok(()) => Ok(()), Err(err) => { diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 455aa424..43464c8f 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -340,7 +340,7 @@ async fn get_ns_mod_download_url(thunderstore_mod_string: &str) -> Result<String /// Returns a vector of modstrings containing the dependencies of a given mod async fn get_mod_dependencies(thunderstore_mod_string: &str) -> Result<Vec<String>, anyhow::Error> { - dbg!(thunderstore_mod_string); + log::info!("Attempting to get dependencies for: {thunderstore_mod_string}"); // TODO: This will crash the thread if not internet connection exist. `match` should be used instead let index = thermite::api::get_package_index().unwrap().to_vec(); @@ -369,6 +369,7 @@ pub async fn fc_download_mod_and_install( game_install: &GameInstall, thunderstore_mod_string: &str, ) -> Result<(), String> { + log::info!("Attempting to install \"{thunderstore_mod_string}\" to {game_install:?}"); // Get mods and download directories let download_directory = format!( "{}/___flightcore-temp-download-dir/", @@ -385,7 +386,7 @@ pub async fn fc_download_mod_and_install( Ok(deps) => deps, Err(err) => return Err(err.to_string()), }; - dbg!(deps.clone()); + log::info!("Mod dependencies: {deps:?}"); // Recursively install dependencies for dep in deps { @@ -439,7 +440,10 @@ pub async fn fc_download_mod_and_install( std::path::Path::new(&mods_directory), ) { Ok(()) => (), - Err(err) => return Err(err.to_string()), + Err(err) => { + log::warn!("libthermite couldn't install mod {thunderstore_mod_string} due to {err:?}",); + return Err(err.to_string()); + } }; Ok(()) diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index 235c35ff..344c0ccf 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -38,6 +38,10 @@ async fn do_install( let filename = format!("northstar-{}.zip", nmod.version); let download_directory = format!("{}/___flightcore-temp-download-dir/", game_path.display()); + log::info!( + "Attempting to create temporary directory {}", + download_directory + ); std::fs::create_dir_all(download_directory.clone())?; let download_path = format!("{}/{}", download_directory, filename); |