feat: 断点续传与色情识别提速/修复,支持 Linux 交叉编译
- feat: 新增续传表 scan_log,重扫跳过已归类文件(尺寸/头尾指纹校验) - fix: 色情识别记录批量入库超 SQLite 999 变量上限,改每 100 条一批 - perf: NudeNet 检测改为多线程推理池(每线程独立模型实例) - perf: 明暗分析 JPEG(YCbCr) 快路径;SQLite 读并发放开;加阶段耗时统计 - fix: 前端色情识别状态由后端如实上报(配置开关+检测服务是否起来) - feat: ffprobe 内嵌按平台拆分,Linux 构建回退系统 ffprobe,支持交叉编译 - docs: README 补充断点续传与 CentOS 交叉编译步骤 - chore: organize.workers 默认 8
This commit is contained in:
@@ -69,9 +69,25 @@ type ScanStatus struct {
|
||||
|
||||
// ============================ 应用级常量 ============================
|
||||
|
||||
// 应用级配置键。目前只存了一个:上次使用的存放目录,方便下次打开页面自动回填。
|
||||
// 应用级配置键。目前只存了两个:上次使用的存放目录、色情检测服务是否真的起来了。
|
||||
const ConfigKeyDestDir = "scan.destDir"
|
||||
|
||||
// nsfwDetectorReadyKey 记录最近一次扫描时色情检测服务是否真的起来了(python+nudenet 可用)。
|
||||
// 配置开了但检测器没起来(没装 python/模型下载失败等)也能区分出来,前端据此提示。
|
||||
const nsfwDetectorReadyKey = "nsfw.detectorReady"
|
||||
|
||||
// setNsfwDetectorReady 把"色情检测服务是否真的起来了"记进数据库(AppConfig)。
|
||||
func (s *ScanService) setNsfwDetectorReady(ready bool) {
|
||||
if s.store == nil {
|
||||
return
|
||||
}
|
||||
v := "0"
|
||||
if ready {
|
||||
v = "1"
|
||||
}
|
||||
_ = s.store.SaveConfig(nsfwDetectorReadyKey, v)
|
||||
}
|
||||
|
||||
// DefaultPickerDirName 用户没指定存放目录时,默认在扫描目录下新建这个文件夹装整理好的文件。
|
||||
const DefaultPickerDirName = "KMP已整理"
|
||||
|
||||
@@ -469,10 +485,11 @@ func (s *ScanService) runScan(ctx context.Context, rootDir, destDir string) erro
|
||||
res.Filter()
|
||||
|
||||
// ---------- 第三步:准备解码器 ----------
|
||||
// 读取视频/音频信息需要 ffprobe。程序里内嵌了一份,用之前先释放到当前目录。
|
||||
// 释放失败就跳过视频/音频整理,图片照常处理。
|
||||
// 读取视频/音频信息需要 ffprobe。Windows 构建内嵌了一份,先释放到当前目录;
|
||||
// Linux 构建没有内嵌,自动回退用系统 PATH 里的 ffprobe(如 /usr/bin/ffprobe)。
|
||||
// 两者都没有就跳过视频/音频整理,图片照常处理。
|
||||
ffprobePath := ""
|
||||
if (len(res.Images) > 0 || len(res.Media) > 0) && probe.HasEmbeddedFFprobe() {
|
||||
if len(res.Images) > 0 || len(res.Media) > 0 {
|
||||
if err := probe.ReleaseFFprobe(); err != nil {
|
||||
fmt.Printf("=== 释放解码器失败, 视频/音频整理将跳过(图片照常处理): %v\n", err)
|
||||
} else {
|
||||
@@ -498,12 +515,14 @@ func (s *ScanService) runScan(ctx context.Context, rootDir, destDir string) erro
|
||||
// 用本机 python + NudeNet 起一个本地检测服务。没装 python/nudenet 时跳过,
|
||||
// 不影响图片整理——检测结果只决定走普通目录还是「图片_敏感」目录。
|
||||
nsfwDet := (*nsfw.Detector)(nil)
|
||||
s.setNsfwDetectorReady(false)
|
||||
if cfg := config.GetAppConfig(); cfg.NSFWEnabled {
|
||||
if d, err := nsfw.Start(cfg.NSFWPython, cfg.NSFWThreshold); err != nil {
|
||||
fmt.Printf("=== 色情识别未启用(图片照常处理): %v\n", err)
|
||||
} else {
|
||||
nsfwDet = d
|
||||
defer nsfwDet.Stop()
|
||||
s.setNsfwDetectorReady(true)
|
||||
fmt.Println("=== 色情识别已启用(NudeNet)")
|
||||
// 清掉上一次的色情识别记录,保证「色情识别」页面显示的是本次扫描的结果
|
||||
if s.store != nil {
|
||||
|
||||
Reference in New Issue
Block a user