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:
2025-06-19 21:07:35 +08:00
parent ea134afa27
commit 957dfe1134
18 changed files with 908 additions and 111 deletions
+13 -1
View File
@@ -10,9 +10,15 @@ import (
"github.com/gin-gonic/gin"
"kenaito-media-picker/internal/config"
"kenaito-media-picker/internal/store"
)
// nsfwDetectorReadyKey 记录"最近一次扫描时色情检测服务是否真的起来了"(存 AppConfig)。
// 配置开了但检测器没起来(没装 python/模型下载失败等)也能区分出来,方便前端提示。
// 由 scan 流程在服务启动成功/失败时写 1/0。
const nsfwDetectorReadyKey = "nsfw.detectorReady"
// NsfwController 色情识别相关接口的"窗口"。
type NsfwController struct {
store *store.Store // 数据库(只读)
@@ -55,7 +61,13 @@ func (c *NsfwController) List(ctx *gin.Context) {
CreatedAt: r.CreatedAt.Format("2006-01-02 15:04:05"),
})
}
Success(ctx, map[string]interface{}{"list": views, "total": len(views)})
Success(ctx, map[string]interface{}{
"list": views,
"total": len(views),
"nsfwEnabled": config.GetAppConfig().NSFWEnabled,
// 没扫描过(空)或上次成功(1)都算可用;只有明确记过失败(0)才提示检测服务没起来
"nsfwDetector": c.store == nil || c.store.GetConfig(nsfwDetectorReadyKey) != "0",
})
}
// Preview 处理 GET /api/nsfw/preview?path=xxx:把指定图片文件返回给浏览器做预览。