mirror of
https://github.com/minio/minio.git
synced 2026-11-16 14:53:19 +00:00
xl: Avoid removing directory content in Delete API (#5548)
Delete & Multi Delete API should not try to remove the directory content. The only permitted case is with zero size object with a trailing slash in its name.
This commit is contained in:
1 parent
db9e83de62
commit
d2d49f6c6c
2 files changed
+22
-7
No files matched your search
+14
-4
@@ -777,8 +777,11 @@ func (xl xlObjects) deleteObject(bucket, object string) error {
|
||||
|
||||
var writeQuorum int
|
||||
var err error
|
||||
|
||||
isDir := hasSuffix(object, slashSeparator)
|
||||
|
||||
// If its a directory request, no need to read metadata.
|
||||
if !hasSuffix(object, slashSeparator) {
|
||||
if !isDir {
|
||||
// Read metadata associated with the object from all disks.
|
||||
metaArr, errs := readAllXLMetadata(xl.getDisks(), bucket, object)
|
||||
|
||||
@@ -800,13 +803,20 @@ func (xl xlObjects) deleteObject(bucket, object string) error {
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
go func(index int, disk StorageAPI) {
|
||||
go func(index int, disk StorageAPI, isDir bool) {
|
||||
defer wg.Done()
|
||||
err := cleanupDir(disk, bucket, object)
|
||||
var err error
|
||||
if isDir {
|
||||
// DeleteFile() simply tries to remove a directory
|
||||
// and will succeed only if that directory is empty.
|
||||
err = disk.DeleteFile(bucket, object)
|
||||
} else {
|
||||
err = cleanupDir(disk, bucket, object)
|
||||
}
|
||||
if err != nil && errors.Cause(err) != errVolumeNotFound {
|
||||
dErrs[index] = err
|
||||
}
|
||||
}(index, disk)
|
||||
}(index, disk, isDir)
|
||||
}
|
||||
|
||||
// Wait for all routines to finish.
|
||||
|
||||
Reference in new issue
Block a user