From b240c7c88a86cb984aa3eb93e5b1d29be12807f6 Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Wed, 21 Oct 2015 18:46:19 -0700 Subject: [PATCH] Support for "rm" of localdir/prefix... --- rm-main.go | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/rm-main.go b/rm-main.go index f9a0117c..955690bd 100644 --- a/rm-main.go +++ b/rm-main.go @@ -17,7 +17,7 @@ package main import ( - "os" + "path/filepath" "strings" "github.com/minio/cli" @@ -123,7 +123,7 @@ func rmAll(url string) { return } for urlPartial2 := range out { - urlFull := urlPartial1 + urlPartial2 + urlFull := filepath.Join(urlPartial1, urlPartial2) newclnt, e := url2Client(urlFull) if e != nil { errorIf(e, "Unable to create client object : "+urlFull+".") @@ -153,7 +153,7 @@ func rmAllIncompleteUploads(url string) { urlPartial1 := url2Dir(url) ch := clnt.List(true, true) for entry := range ch { - urlFull := urlPartial1 + entry.Content.Name + urlFull := filepath.Join(urlPartial1, entry.Content.Name) newclnt, e := url2Client(urlFull) if e != nil { errorIf(e, "Unable to create client object : "+urlFull+".") @@ -215,25 +215,6 @@ func checkRmSyntax(ctx *cli.Context) { } fatalIf(errDummy().Trace(), helpStr) } - if u.Type == client.Filesystem { - // For local file system we don't support "mc rm fileprefix..." just like the behavior of "mc ls fileprefix..." - // So recursive delete has to be of the form "mc rm dir1/dir2/..." - isRecursive := isURLRecursive(url) - path := stripRecursiveURL(url) - if isRecursive && (strings.HasSuffix(path, string(u.Separator)) == false) { - helpStr := "Usage : mc rm " + path + string(u.Separator) + recursiveSeparator + " force" - fatalIf(errDummy().Trace(), helpStr) - } - _, content, err := url2Stat(path) - if err != nil { - fatalIf(err.Trace(), "url2stat error on "+url) - } - if content.Type&os.ModeDir != 0 && !isRecursive { - helpStr := "Usage : mc rm " + url + string(u.Separator) + recursiveSeparator + " force" - fatalIf(errDummy().Trace(), helpStr) - } - continue - } } }