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
2 changes: 2 additions & 0 deletions src-tauri/Cargo.lock

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

4 changes: 4 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ sysinfo = "0.32"
machine-uid = "0.5"
sha2 = "0.10"

[dev-dependencies]
filetime = "0.2"
tempfile = "3"

[profile.release]
# 保留调试符号以生成 PDB 文件,便于崩溃分析
debug = true
Expand Down
46 changes: 1 addition & 45 deletions src-tauri/src/commands/file_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,51 +294,7 @@ pub fn get_data_dir() -> Result<String, String> {
Ok(data_dir.to_string_lossy().to_string())
}

/// 删除 debug 目录中的 .log 文件,可选择排除一个当前正在使用的日志文件
#[tauri::command]
pub fn clear_log_files(exclude_file_name: Option<String>) -> Result<u64, String> {
let debug_dir = get_app_data_dir()?.join("debug");

if !debug_dir.exists() {
return Ok(0);
}

let mut deleted = 0_u64;
let entries = std::fs::read_dir(&debug_dir)
.map_err(|e| format!("读取日志目录失败 [{}]: {}", debug_dir.display(), e))?;

for entry in entries {
let entry = match entry {
Ok(entry) => entry,
Err(_) => continue,
};
let path = entry.path();
if !path.is_file() {
continue;
}

let Some(name) = path.file_name().and_then(|name| name.to_str()) else {
continue;
};

if !name.ends_with(".log") {
continue;
}

if exclude_file_name.as_deref() == Some(name) {
continue;
}

match std::fs::remove_file(&path) {
Ok(()) => deleted = deleted.saturating_add(1),
Err(e) => log::debug!("Failed to delete log file [{}]: {}", path.display(), e),
}
}

Ok(deleted)
}

/// 获取当前工作目录
/// 获取当前工作目录。
#[tauri::command]
pub fn get_cwd() -> Result<String, String> {
std::env::current_dir()
Expand Down
Loading