diff --git a/cmd/client-s3.go b/cmd/client-s3.go index bee90284..7bd6179d 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -1004,6 +1004,12 @@ func (c *s3Client) listInRoutine(contentCh chan *clientContent) { } return } + + // Avoid sending an empty directory when we are specifically listing it + if strings.HasSuffix(object.Key, string(c.targetURL.Separator)) && o == object.Key { + continue + } + content := &clientContent{} url := *c.targetURL // Join bucket and incoming object key. diff --git a/cmd/rm-main.go b/cmd/rm-main.go index 94a45719..d62e3714 100644 --- a/cmd/rm-main.go +++ b/cmd/rm-main.go @@ -254,7 +254,12 @@ func rmAll(targetAlias, targetURL, prefix string, isRecursive, isIncomplete, isF // Regular type. if !isFake { - if err = rmObject(targetAlias, entry.URL.String(), isIncomplete); err != nil { + entryPath := entry.URL.String() + // Add '/' to force removing empty directories + if entry.Type.IsDir() { + entryPath += string(entry.URL.Separator) + } + if err = rmObject(targetAlias, entryPath, isIncomplete); err != nil { errorIf(err.Trace(entry.URL.String()), "Unable to remove ‘"+entry.URL.String()+"’.") continue }