Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 1 addition & 45 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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
Expand Down
42 changes: 32 additions & 10 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ fn configure_log() -> TauriPlugin<Wry> {
.unwrap_or("".to_string());
out.finish(format_args!(
"{}[{}][{}{}{}] {}",
time::OffsetDateTime::now_local()
.unwrap()
time::OffsetDateTime::now_utc()
.format(&format)
.unwrap(),
record.level(),
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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() {
Expand Down
16 changes: 10 additions & 6 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -100,22 +100,26 @@
"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": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
"timestampUrl": "",
"webviewInstallMode": {
"type": "downloadBootstrapper"
}
}
},
"security": {
Expand Down