From 02ccc97809be135262f02548c4b9e2bcc3b5267a Mon Sep 17 00:00:00 2001 From: kawaiinekololis Date: Wed, 17 Jan 2024 09:52:10 +0100 Subject: [PATCH] v0.2.2 b2 --- src-tauri/src/app/gui.rs | 1 + src-tauri/src/main.rs | 22 +++++++++++++++++----- src-tauri/src/minecraft/version.rs | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/app/gui.rs b/src-tauri/src/app/gui.rs index f51cd21..e16f165 100644 --- a/src-tauri/src/app/gui.rs +++ b/src-tauri/src/app/gui.rs @@ -413,6 +413,7 @@ pub fn gui_main() { } } + info!("Successfully setup window"); Ok(()) }) .manage(AppState { diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 20458fe..ccf7ba4 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -28,7 +28,7 @@ use once_cell::sync::Lazy; use anyhow::{Result, Context}; use directories::ProjectDirs; use reqwest::Client; -use tracing::{debug, info}; +use tracing::{debug, info, error}; use tracing_subscriber::layer::SubscriberExt; use utils::ARCHITECTURE; @@ -64,6 +64,19 @@ static HTTP_CLIENT: Lazy = Lazy::new(|| { client }); +/// Creates a directory tree if it doesn't exist +macro_rules! mkdir { + ($path:expr) => { + // Check if directory exists + if !$path.exists() { + // Create directory + if let Err(e) = fs::create_dir_all($path) { + error!("Failed to create directory {:?}: {}", $path, e); + } + } + }; +} + pub fn main() -> Result<()> { use tracing_subscriber::{fmt, EnvFilter}; @@ -93,12 +106,11 @@ pub fn main() -> Result<()> { info!("Creating application directory"); debug!("Application directory: {:?}", LAUNCHER_DIRECTORY.data_dir()); debug!("Config directory: {:?}", LAUNCHER_DIRECTORY.config_dir()); - fs::create_dir_all(LAUNCHER_DIRECTORY.data_dir()) - .context("data_dir failed to create.")?; - fs::create_dir_all(LAUNCHER_DIRECTORY.config_dir()) - .context("config_dir failed to create.")?; + mkdir!(LAUNCHER_DIRECTORY.data_dir()); + mkdir!(LAUNCHER_DIRECTORY.config_dir()); // app + info!("Starting GUI"); app::gui::gui_main(); info!("Launcher exited"); diff --git a/src-tauri/src/minecraft/version.rs b/src-tauri/src/minecraft/version.rs index 5456bbf..ae7b181 100644 --- a/src-tauri/src/minecraft/version.rs +++ b/src-tauri/src/minecraft/version.rs @@ -20,7 +20,7 @@ use std::{collections::HashMap, fmt, marker::PhantomData, path::{Path, PathBuf}, str::FromStr}; use anyhow::{Result, Context}; -use tracing::{debug, info, field::debug}; +use tracing::{debug, info}; use tokio::fs; use serde::{Deserialize, Deserializer, de::{self, MapAccess, Visitor}}; use void::Void;