Browse Source

增加后缀异常处理

master
xyiege 6 months ago
parent
commit
8e94dab15d
  1. 2
      aufs/core/AuFile.go
  2. 15
      scagent/core/JsonRpc.go

2
aufs/core/AuFile.go

@ -52,8 +52,6 @@ func Flist(w http.ResponseWriter, r *http.Request) {
basepath := "/www/wwwroot" basepath := "/www/wwwroot"
// 拼装路径,并转位unix路径 // 拼装路径,并转位unix路径
newpath := filepath.ToSlash(filepath.Join(basepath, wdir)) newpath := filepath.ToSlash(filepath.Join(basepath, wdir))
fmt.Printf("newpath:%v\n", newpath)
// basepath = fmt.Sprintf("%v%v", basepath, wdir) // basepath = fmt.Sprintf("%v%v", basepath, wdir)
// 调用远程方法 // 调用远程方法
var reply string var reply string

15
scagent/core/JsonRpc.go

@ -6,6 +6,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"scagent/util" "scagent/util"
"strings"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -168,9 +169,13 @@ func scanFileUnderPath(rootDir string, scope string, logger *zap.Logger, replay
// 获取文件的后缀 // 获取文件的后缀
func getFileSuffix(filename string) string { func getFileSuffix(filename string) string {
// 获取文件的后缀 // 文件判断是否有文件的后缀
suffix := filepath.Ext(filename) if strings.Contains(filename, ".") {
// 去掉. // 获取文件的后缀
suffix = suffix[1:] suffix := filepath.Ext(filename)
return suffix // 去掉.
suffix = suffix[1:]
return suffix
}
return ""
} }

Loading…
Cancel
Save