refactor: 合并 NSFW 数据到 media_info 表

This commit is contained in:
2025-07-26 21:05:51 +08:00
parent 95e6297076
commit 59b0206cf1
12 changed files with 159 additions and 463 deletions
+4 -7
View File
@@ -524,18 +524,13 @@ func (s *ScanService) runScan(ctx context.Context, rootDir, destDir string) erro
defer nsfwDet.Stop()
s.setNsfwDetectorReady(true)
fmt.Println("=== 色情识别已启用(NudeNet)")
// 清掉上一次的色情识别记录,保证「色情识别」页面显示的是本次扫描的结果
if s.store != nil {
if err := s.store.ClearNsfw(); err != nil {
fmt.Printf("=== 清空旧色情识别记录失败: %v\n", err)
}
}
}
}
org := organize.New(pickerDir, ffprobePath, ffmpegPath, s.store, ctx)
org.SetNSFWDetector(nsfwDet)
org.SetRotateImages(config.GetAppConfig().RotateImages)
org.SetMoveFiles(config.GetAppConfig().MoveFiles)
// 整个"整理"分两个阶段,界面上共用一条进度条:
// 归类阶段:图片、视频/音频分两批处理。进度 = 已处理文件数 / 全部待整理文件数
@@ -575,7 +570,9 @@ func (s *ScanService) runScan(ctx context.Context, rootDir, destDir string) erro
if config.GetAppConfig().MoveFiles {
org.Flush()
} else {
fmt.Println("=== 配置 organize.moveFiles=false,跳过文件移动")
// 不移动文件,但仍需写入媒体记录到数据库
org.FlushRecordsOnly()
fmt.Println("=== 配置 organize.moveFiles=false,跳过文件移动(媒体记录已保存)")
}
// 把进度条顶满 100%,再打印"整理完成"