Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复重复输出 #23

Merged
merged 3 commits into from
Dec 11, 2024
Merged
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
5 changes: 4 additions & 1 deletion folders_description.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ Roaming:
Mozilla: "Firefox"
#firefox: "Mozilla Firefox 浏览器配置文件"
clash_win: "Clash for Windows 配置文件"
RustDesk: "RustDesk 配置文件"
VMWare: "VMWare 配置文件"
Motrix: "Motrix 配置文件"
zen: "Zen 网络配置"
Local:
# 示例:文件夹名: "描述"
BCUT: "必剪数据"
Temp: "系统临时文件"
myapp: "自定义应用配置文件"
Expand All @@ -20,4 +22,5 @@ Local:
Obsidian: "Obsidian 安装位置"
zen: "Zen 浏览器用户数据"
rustdesk: "RustDesk 用户数据"
LocalLow:
LocalLow:
# 示例:文件夹名: "描述"
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ mod confirmation; // 确认删除模块
mod delete; // 引入删除模块
mod ignore; // 引入忽略模块
mod logger; // 引入日志模块
mod move_module;
mod open;
mod move_module; // 移动文件夹,使用 mklink 指令
mod open; // 调用资源管理器打开文件夹
mod scanner; // 引入扫盘模块
mod ui; // 引入 ui 模块
mod utils; // 文件夹大小计算模块
mod yaml_loader;
mod yaml_loader; // 文件描述

use ui::AppDataCleaner;

Expand Down
6 changes: 3 additions & 3 deletions src/scanner.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::path::Path;
use std::sync::mpsc::Sender;
use std::thread;
use std::{fs, path::PathBuf};
use std::path::Path;

use dirs_next as dirs;
use crate::logger; // 引入日志模块
use crate::logger;
use dirs_next as dirs; // 引入日志模块

pub fn scan_appdata(tx: Sender<(String, u64)>, folder_type: &str) {
println!("开始扫描 {} 类型的文件夹", folder_type);
Expand Down
9 changes: 8 additions & 1 deletion src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct AppDataCleaner {
ignored_folders: HashSet<String>, // 忽略文件夹集合
move_module: move_module::MoveModule, // 移动模块实例
folder_descriptions: Option<FolderDescriptions>,
yaml_error_logged: bool, // 新增字段,用于标记是否已经记录过错误
}

impl Default for AppDataCleaner {
Expand All @@ -45,6 +46,7 @@ impl Default for AppDataCleaner {
ignored_folders: ignore::load_ignored_folders(),
move_module: Default::default(),
folder_descriptions: None,
yaml_error_logged: false, // 初始时假定未记录过错误
}
}
}
Expand Down Expand Up @@ -80,7 +82,12 @@ impl eframe::App for AppDataCleaner {
if self.folder_descriptions.is_none() {
match FolderDescriptions::load_from_yaml("folders_description.yaml") {
Ok(descriptions) => self.folder_descriptions = Some(descriptions),
Err(e) => eprintln!("加载 YAML 文件失败: {}", e),
Err(e) => {
if !self.yaml_error_logged {
eprintln!("加载 YAML 文件失败: {}", e);
self.yaml_error_logged = true; // 记录错误,避免重复输出
}
}
}
}

Expand Down