update
Some checks failed
Rust CI / Build Release (push) Has been cancelled
Rust CI / Cargo Check (push) Has been cancelled

This commit is contained in:
lychang
2026-07-19 16:34:04 +08:00
parent 82653c1a6c
commit 093924ea99
10 changed files with 37 additions and 901 deletions

View File

@@ -47,27 +47,29 @@ async fn main() -> std::io::Result<()> {
}
};
// 自动迁移老数据库
if let Some(ref old_db_cfg) = config.old_db {
if old_db_cfg.auto_migrate {
info!("[迁移] 检测到 old_db 配置,自动迁移: {}", old_db_cfg.path);
match db.migrate_from_old_db(&old_db_cfg.path).await {
Ok(stats) => info!("[迁移] {}", db.migration_summary(&stats)),
Err(e) => error!("[迁移] 失败: {}", e),
}
}
}
let image_processor = Arc::new(image_processor::ImageProcessor::new(config.storage.clone()));
// 后台导入本地相册
// 后台导入本地相册 + 自动解析title
let config_clone = config.clone();
let db_clone = Arc::clone(&db);
let auto_parse = true;
tokio::spawn(async move {
info!("[后台任务] 开始扫描图片目录并导入新相册...");
match services::import::import_existing_data(&config_clone, db_clone, None).await {
Ok(_) => info!("[后台任务] 相册导入完成"),
Err(e) => error!("[后台任务] 相册导入失败: {}", e),
let import_ok = match services::import::import_existing_data(&config_clone, Arc::clone(&db_clone), None).await {
Ok(_) => {
info!("[后台任务] 相册导入完成");
true
}
Err(e) => {
error!("[后台任务] 相册导入失败: {}", e);
false
}
};
if import_ok && auto_parse {
info!("[后台任务] 开始解析相册 title(提取人名 + 标签)...");
let (persons, tags) = engine::pipeline::process_all_albums(&db_clone).await;
info!("[后台任务] Title 解析完成:{} 个人名,{} 个标签", persons, tags);
}
});