fix: log目录冲突导致应用无限重启的bug

This commit is contained in:
NanGua-QWQ
2026-03-25 19:44:44 +08:00
parent dab3d811ec
commit 207468d14f
3 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2021"
rust-version = "1.70"
[lib]
name = "secscore"
name = "secscore_lib"
crate-type = ["staticlib", "cdylib", "lib"]
[build-dependencies]
+1 -1
View File
@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
secscore::run();
secscore_lib::run();
}
+7 -2
View File
@@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use std::fs::{self, File, OpenOptions};
use std::io::{BufRead, BufReader, Write};
use std::path::PathBuf;
use tauri::{AppHandle, Emitter};
use tauri::{AppHandle, Emitter, Manager};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum LogLevel {
@@ -68,7 +68,12 @@ impl LoggerService {
}
}
pub async fn initialize(&mut self, _app_handle: &AppHandle) -> Result<(), String> {
pub async fn initialize(&mut self, app_handle: &AppHandle) -> Result<(), String> {
let app_data_dir = app_handle
.path()
.app_data_dir()
.map_err(|e| format!("Failed to get app data directory: {}", e))?;
self.log_dir = app_data_dir.join("logs");
fs::create_dir_all(&self.log_dir).map_err(|e| e.to_string())?;
Ok(())
}