refactor: 将文件移动改为独立接口,扫描完成后手动触发

This commit is contained in:
2025-07-29 21:18:35 +08:00
parent 59b0206cf1
commit 2e01f6c3c9
7 changed files with 193 additions and 35 deletions
+1 -5
View File
@@ -19,7 +19,6 @@ import (
// - FFmpegPath:ffmpeg 程序路径(用于把带 EXIF 旋转标记的图片转正);留空自动在 PATH 里找
// - RotateImages:是否处理图片 EXIF 旋转(默认 true);false 则完全不处理,按存储方向/尺寸归类
// - Workers:探测/MIME/移动阶段的并发 worker 数(默认 4;设 0 表示用满全部 CPU 核数)
// - MoveFiles:扫描完成后是否移动文件到分类目录(默认 true)
// - NSFWEnabled:是否开启色情图片识别(本地 python + NudeNet,默认 false)
// - NSFWPython:python 可执行文件路径;留空自动在 PATH 里找
// - NSFWThreshold:判定阈值 0~1(默认 0.5)
@@ -30,7 +29,6 @@ type Config struct {
FFmpegPath string
RotateImages bool
Workers int
MoveFiles bool
NSFWEnabled bool
NSFWPython string
NSFWThreshold float64
@@ -47,7 +45,7 @@ func GetAppConfig() Config {
// LoadAppConfig 从 application.properties 读配置;文件不存在就用默认值。
func LoadAppConfig() {
// 先给一套默认值
appConfig = Config{Port: 8080, Dsn: "media-info.db", AutoOpen: true, RotateImages: true, Workers: 4, MoveFiles: true, NSFWThreshold: 0.5}
appConfig = Config{Port: 8080, Dsn: "media-info.db", AutoOpen: true, RotateImages: true, Workers: 4, NSFWThreshold: 0.5}
p, err := properties.LoadFile("application.properties", properties.UTF8)
if err != nil {
@@ -72,8 +70,6 @@ func LoadAppConfig() {
appConfig.Workers = n
}
}
// 扫描完成后是否移动文件:默认 true
appConfig.MoveFiles = p.GetBool("organize.moveFiles", true)
// 色情识别:默认关;python 路径留空自动在 PATH 找;阈值只认 0~1 之间的小数
appConfig.NSFWEnabled = p.GetBool("nsfw.enabled", false)
if v, ok := p.Get("nsfw.python"); ok && v != "" {