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
+44
View File
@@ -0,0 +1,44 @@
package store
import (
"fmt"
"os"
"path/filepath"
"testing"
"time"
)
func TestSaveNsfwBatchLarge(t *testing.T) {
db := filepath.Join(t.TempDir(), "test.db")
s, err := Open(db)
if err != nil {
t.Fatalf("Open: %v", err)
}
defer func() {
s.Close()
os.Remove(db)
}()
// 3000 条,远超 SQLite 999 变量上限(旧代码会报 too many SQL variables)
records := make([]*NsfwRecord, 0, 3000)
for i := 0; i < 3000; i++ {
records = append(records, &NsfwRecord{
FilePath: fmt.Sprintf("/path/%d.jpg", i),
FileName: fmt.Sprintf("%d.jpg", i),
Score: 0.5,
Threshold: 0.2,
MovedPath: fmt.Sprintf("/moved/%d.jpg", i),
CreatedAt: time.Now(),
})
}
if err := s.SaveNsfwBatch(records); err != nil {
t.Fatalf("SaveNsfwBatch: %v", err)
}
list, err := s.ListNsfw()
if err != nil {
t.Fatalf("ListNsfw: %v", err)
}
if len(list) != 3000 {
t.Fatalf("got %d records, want 3000", len(list))
}
}