update
This commit is contained in:
33
src/main.rs
33
src/main.rs
@@ -49,27 +49,28 @@ async fn main() -> std::io::Result<()> {
|
||||
|
||||
let image_processor = Arc::new(image_processor::ImageProcessor::new(config.storage.clone()));
|
||||
|
||||
// 后台导入本地相册 + 自动解析title
|
||||
// 后台任务1: 扫描导入新相册
|
||||
let config_clone = config.clone();
|
||||
let db_clone = Arc::clone(&db);
|
||||
let auto_parse = true;
|
||||
let db_import = Arc::clone(&db);
|
||||
tokio::spawn(async move {
|
||||
info!("[后台任务] 开始扫描图片目录并导入新相册...");
|
||||
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
|
||||
}
|
||||
};
|
||||
match services::import::import_existing_data(&config_clone, db_import, None).await {
|
||||
Ok(_) => info!("[后台任务] 相册导入完成"),
|
||||
Err(e) => error!("[后台任务] 相册导入失败: {}", e),
|
||||
}
|
||||
});
|
||||
|
||||
if import_ok && auto_parse {
|
||||
info!("[后台任务] 开始解析相册 title(提取人名 + 标签)...");
|
||||
let (persons, tags) = engine::pipeline::process_all_albums(&db_clone).await;
|
||||
// 后台任务2: 自动解析已有相册的 title(增量,针对老版本 db)
|
||||
let db_parse = Arc::clone(&db);
|
||||
tokio::spawn(async move {
|
||||
// 等待 3 秒让导入任务先开始(导入后也会触发解析,避免重复)
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
|
||||
info!("[后台任务] 检查是否有未解析的相册(针对老版本 db)...");
|
||||
let (persons, tags) = engine::pipeline::process_all_albums(&db_parse).await;
|
||||
if persons > 0 || tags > 0 {
|
||||
info!("[后台任务] Title 解析完成:{} 个人名,{} 个标签", persons, tags);
|
||||
} else {
|
||||
info!("[后台任务] 所有相册已解析,无需处理");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user