From dbf0de4ce1a03323d46beafb1ede36302d61534e Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 25 Aug 2022 00:19:08 -0700 Subject: [PATCH] minor clean up --- weed/command/fix.go | 6 +++++- weed/util/file_util.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/weed/command/fix.go b/weed/command/fix.go index 8ab879d3b..46cfc40db 100644 --- a/weed/command/fix.go +++ b/weed/command/fix.go @@ -62,6 +62,10 @@ func (scanner *VolumeFileScanner4Fix) VisitNeedle(n *needle.Needle, offset int64 func runFix(cmd *Command, args []string) bool { for _, arg := range args { basePath, f := path.Split(util.ResolvePath(arg)) + if util.FolderExists(arg) { + basePath = arg + f = "" + } files := []fs.DirEntry{} if f == "" { @@ -72,7 +76,7 @@ func runFix(cmd *Command, args []string) bool { } files = fileInfo } else { - fileInfo, err := os.Stat(basePath + f) + fileInfo, err := os.Stat(arg) if err != nil { fmt.Println(err) return false diff --git a/weed/util/file_util.go b/weed/util/file_util.go index 3cd4b1b23..346de76db 100644 --- a/weed/util/file_util.go +++ b/weed/util/file_util.go @@ -45,6 +45,16 @@ func FileExists(filename string) bool { } +func FolderExists(folder string) bool { + + fileInfo, err := os.Stat(folder) + if err != nil { + return false + } + return fileInfo.IsDir() + +} + func CheckFile(filename string) (exists, canRead, canWrite bool, modTime time.Time, fileSize int64) { exists = true fi, err := os.Stat(filename)