fix: 修复扫描/探测/移动三个健壮性问题
- scanner: filepath.Ext 替代 path.Ext,修复 Windows 点号目录名扩展名解析错误 - scanner: Walk 遇不可访问路径仅告警跳过,不再整体中止扫描 - probe: ffprobe 探测增加 30s 超时,避免损坏文件卡死程序 - mover: copyFile 失败时清理半截目标文件,消除双重 Close - 新增代码审查报告 bug20260814.md
This commit is contained in:
@@ -4,7 +4,6 @@ package scanner
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -41,7 +40,9 @@ func Scan(opts Options) (*Result, error) {
|
||||
res := &Result{}
|
||||
err := filepath.Walk(opts.RootDir, func(currentPath string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
// 单个路径访问失败(权限不足/损坏)不中止整体扫描,仅告警后跳过该子树
|
||||
fmt.Printf("=== 扫描跳过(无法访问): %s, 错误: %v\n", currentPath, err)
|
||||
return nil
|
||||
}
|
||||
if info.IsDir() {
|
||||
if opts.SkipDir != "" && currentPath == opts.SkipDir {
|
||||
@@ -57,7 +58,7 @@ func Scan(opts Options) (*Result, error) {
|
||||
res.Files = append(res.Files, File{
|
||||
Path: currentPath,
|
||||
Name: info.Name(),
|
||||
Ext: path.Ext(currentPath),
|
||||
Ext: filepath.Ext(currentPath),
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user