diff --git a/internal/pcscommand/upload.go b/internal/pcscommand/upload.go index 9653a81..133183b 100644 --- a/internal/pcscommand/upload.go +++ b/internal/pcscommand/upload.go @@ -34,11 +34,10 @@ type ( // RunRapidUpload 执行秒传文件, 前提是知道文件的大小, md5, 前256KB切片的 md5, crc32 func RunRapidUpload(targetPath, contentMD5, sliceMD5, crc32 string, length int64) { - targetPath = strings.Replace(targetPath, `[`, `\[`, -1) - targetPath = strings.Replace(targetPath, `]`, `\]`, -1) - err := matchPathByShellPatternOnce(&targetPath) + dirname := path.Dir(targetPath) + err := matchPathByShellPatternOnce(&dirname) if err != nil { - fmt.Printf("警告: %s, 获取网盘路径 %s 错误, %s\n", baidupcs.OperationRapidUpload, targetPath, err) + fmt.Printf("警告: %s, 获取网盘路径 %s 错误, %s\n", baidupcs.OperationRapidUpload, dirname, err) } err = GetBaiduPCS().RapidUpload(targetPath, contentMD5, sliceMD5, crc32, length) diff --git a/pcsutil/file.go b/pcsutil/file.go index b2c0a9a..a89c319 100644 --- a/pcsutil/file.go +++ b/pcsutil/file.go @@ -88,7 +88,7 @@ func WalkDir(dirPth, suffix string) (files []string, err error) { if err != nil { return err } - if fi.IsDir() { // 忽略目录 + if fi.IsDir() || fi.Size() == 0 { // 忽略目录和空文件 return nil } if fi.Mode()&os.ModeSymlink != 0 { // 读取 symbol link