github.com/fzfile/BaiduPCS-Go@v0.0.0-20200606205115-4408961cf336/internal/pcscommand/fixmd5.go (about) 1 package pcscommand 2 3 import ( 4 "fmt" 5 "github.com/fzfile/BaiduPCS-Go/baidupcs" 6 ) 7 8 // RunFixMD5 执行修复md5 9 func RunFixMD5(pcspaths ...string) { 10 absPaths, err := matchPathByShellPattern(pcspaths...) 11 if err != nil { 12 fmt.Println(err) 13 return 14 } 15 16 pcs := GetBaiduPCS() 17 finfoList, err := pcs.FilesDirectoriesBatchMeta(absPaths...) 18 if err != nil { 19 fmt.Println(err) 20 return 21 } 22 23 for k, finfo := range finfoList { 24 err := pcs.FixMD5ByFileInfo(finfo) 25 if err == nil { 26 fmt.Printf("[%d] - [%s] 修复md5成功\n", k, finfo.Path) 27 continue 28 } 29 30 if err.GetError() == baidupcs.ErrFixMD5Failed { 31 fmt.Printf("[%d] - [%s] 修复md5失败, 可能是服务器未刷新\n", k, finfo.Path) 32 continue 33 } 34 fmt.Printf("[%d] - [%s] 修复md5失败, 错误信息: %s\n", k, finfo.Path, err) 35 } 36 }