diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index c9ab45b..bb64638 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler" @@ -2027,7 +2027,6 @@ dependencies = [ "time 0.3.36", "tokio", "trash", - "windows 0.32.0", ] [[package]] @@ -4342,19 +4341,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbedf6db9096bc2364adce0ae0aa636dcd89f3c3f2cd67947062aaf0ca2a10ec" -dependencies = [ - "windows_aarch64_msvc 0.32.0", - "windows_i686_gnu 0.32.0", - "windows_i686_msvc 0.32.0", - "windows_x86_64_gnu 0.32.0", - "windows_x86_64_msvc 0.32.0", -] - [[package]] name = "windows" version = "0.37.0" @@ -4547,12 +4533,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" -[[package]] -name = "windows_aarch64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" - [[package]] name = "windows_aarch64_msvc" version = "0.37.0" @@ -4583,12 +4563,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" -[[package]] -name = "windows_i686_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" - [[package]] name = "windows_i686_gnu" version = "0.37.0" @@ -4625,12 +4599,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" -[[package]] -name = "windows_i686_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" - [[package]] name = "windows_i686_msvc" version = "0.37.0" @@ -4661,12 +4629,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" -[[package]] -name = "windows_x86_64_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" - [[package]] name = "windows_x86_64_gnu" version = "0.37.0" @@ -4715,12 +4677,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" -[[package]] -name = "windows_x86_64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" - [[package]] name = "windows_x86_64_msvc" version = "0.37.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index a4e1ef9..b67d55f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -10,12 +10,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] -tauri-build = { version = "1.5.2", features = [] } +tauri-build = { version = "1.5.1", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "^1.6.7", features = [ "process-exit", "process-relaunch", "fs-copy-file", "clipboard-read-text", "clipboard-write-text", "dialog-ask", "dialog-confirm", "dialog-open", "dialog-save", "fs-create-dir", "fs-exists", "fs-read-dir", "fs-read-file", "fs-rename-file", "fs-write-file", "path-all", "shell-open", "window-center", "window-close", "window-create", "window-hide", "window-maximize", "window-minimize", "window-print", "window-set-decorations", "window-set-focus", "window-set-fullscreen", "window-set-icon", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] } +tauri = { version = "1.5.4", features = [ "process-exit", "process-relaunch", "fs-copy-file", "clipboard-read-text", "clipboard-write-text", "dialog-ask", "dialog-confirm", "dialog-open", "dialog-save", "fs-create-dir", "fs-exists", "fs-read-dir", "fs-read-file", "fs-rename-file", "fs-write-file", "path-all", "shell-open", "window-center", "window-close", "window-create", "window-hide", "window-maximize", "window-minimize", "window-print", "window-set-decorations", "window-set-focus", "window-set-fullscreen", "window-set-icon", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] } tauri-plugin-fs-watch = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } trash = "3.0.2" tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } @@ -27,11 +27,6 @@ infer = "0.3" tokio = { version = "1", features = ["time"] } tauri-plugin-pty = "0.0.8" -[dev-dependencies] -windows = "0.32.0" - - - [features] # by default Tauri runs in production mode # when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index a13a6e7..618499a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -299,8 +299,7 @@ fn configure_log() -> TauriPlugin { .unwrap_or("".to_string()); out.finish(format_args!( "{}[{}][{}{}{}] {}", - time::OffsetDateTime::now_local() - .unwrap() + time::OffsetDateTime::now_utc() .format(&format) .unwrap(), record.level(), @@ -333,15 +332,16 @@ fn configure_log_path(app: &mut App) { } let format = time::format_description::parse("[year]-[month]-[day]-[hour][minute]").unwrap(); - let time = time::OffsetDateTime::now_local() - .unwrap() + let time = time::OffsetDateTime::now_utc() .format(&format) .unwrap(); let log_name = format!("nucleus_log-{}.log", time); // changing the default log name to something more meaningful let new_log_path = app_log_dir.join(log_name); - fs::rename(old_log_path, new_log_path).unwrap(); + if let Err(e) = fs::rename(&old_log_path, &new_log_path) { + error!("Failed to rename log file: {}", e); + } } fn load_settings(app: &mut App) { @@ -368,14 +368,34 @@ fn load_settings(app: &mut App) { } } ); - let appdata_local = tauri::api::path::app_local_data_dir(&app.config()).unwrap(); + + let appdata_local = match tauri::api::path::app_local_data_dir(&app.config()) { + Some(path) => path, + None => { + error!("Failed to get app local data directory"); + return; + } + }; + + // Create the directory if it doesn't exist + if let Err(e) = fs::create_dir_all(&appdata_local) { + error!("Failed to create app data directory: {}", e); + return; + } + let settings_path = appdata_local.join("default_settings.json"); #[cfg(debug_assertions)] - fs::write(&settings_path, default_settings.to_string()).unwrap(); + if let Err(e) = fs::write(&settings_path, default_settings.to_string()) { + error!("Failed to write default settings: {}", e); + return; + } - if !settings_path.try_exists().unwrap() { - fs::write(&settings_path, default_settings.to_string()).unwrap(); + if !settings_path.try_exists().unwrap_or(false) { + if let Err(e) = fs::write(&settings_path, default_settings.to_string()) { + error!("Failed to create default settings file: {}", e); + return; + } info!( "Default settings file not found. Created a new default settings file. Path: {:?}", &settings_path @@ -395,7 +415,9 @@ fn load_settings(app: &mut App) { .defaults(defaults) .build(); - settings_store.load().unwrap(); + if let Err(e) = settings_store.load() { + error!("Failed to load settings: {}", e); + } } fn main() { diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 184ef79..28c3d84 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,10 +1,10 @@ { + "$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/1.5.4/tooling/cli/schema.json", "build": { "beforeBuildCommand": "yarn build", "beforeDevCommand": "yarn dev", "devPath": "http://localhost:8080", - "distDir": "../dist", - "withGlobalTauri": false + "distDir": "../dist" }, "package": { "productName": "nucleus", @@ -100,14 +100,15 @@ "icons/icon.icns", "icons/icon.ico" ], - "identifier": "nucleus", + "identifier": "com.nucleus.app", "longDescription": "", "macOS": { "entitlements": null, "exceptionDomain": "", - "frameworks": [], + "frameworks": ["AppKit", "WebKit", "Security"], "providerShortName": null, - "signingIdentity": null + "signingIdentity": null, + "minimumSystemVersion": "10.13" }, "resources": [], "shortDescription": "", @@ -115,7 +116,10 @@ "windows": { "certificateThumbprint": null, "digestAlgorithm": "sha256", - "timestampUrl": "" + "timestampUrl": "", + "webviewInstallMode": { + "type": "downloadBootstrapper" + } } }, "security": {