Correct behavior of listing and removing empty directories (#1851)
* Listing empty directy returns empty entries * Remove empty directories in rm cmd
This commit is contained in:
committed by
Harshavardhana
parent
01f0c35651
commit
53ab0168e4
@@ -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.
|
||||
|
||||
+6
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user