mirror of
https://github.com/minio/minio.git
synced 2025-11-22 18:47:43 -05: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:
11
cmd/posix.go
11
cmd/posix.go
@@ -24,6 +24,7 @@ import (
|
||||
slashpath "path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
@@ -860,9 +861,13 @@ func deleteFile(basePath, deletePath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Recursively go down the next path and delete again.
|
||||
// Errors for parent directories shouldn't trickle down.
|
||||
deleteFile(basePath, slashpath.Dir(deletePath))
|
||||
// Trailing slash is removed when found to ensure
|
||||
// slashpath.Dir() to work as intended.
|
||||
deletePath = strings.TrimSuffix(deletePath, slashSeparator)
|
||||
deletePath = slashpath.Dir(deletePath)
|
||||
|
||||
// Delete parent directory. Errors for parent directories shouldn't trickle down.
|
||||
deleteFile(basePath, deletePath)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user