mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
fix: skip access checks further for known buckets (#17934)
This commit is contained in:
@@ -38,8 +38,7 @@ func access(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Forked from Golang but chooses fast path upon os.Mkdir()
|
||||
// error to avoid os.Lstat() call.
|
||||
// Forked from Golang but chooses to avoid performing lookup
|
||||
//
|
||||
// osMkdirAll creates a directory named path,
|
||||
// along with any necessary parents, and returns nil,
|
||||
@@ -49,15 +48,6 @@ func access(name string) error {
|
||||
// If path is already a directory, MkdirAll does nothing
|
||||
// and returns nil.
|
||||
func osMkdirAll(dirPath string, perm os.FileMode) error {
|
||||
// Fast path: if we can tell whether path is a directory or file, stop with success or error.
|
||||
err := Access(dirPath)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !osIsNotExist(err) {
|
||||
return &os.PathError{Op: "mkdir", Path: dirPath, Err: err}
|
||||
}
|
||||
|
||||
// Slow path: make sure parent exists and then call Mkdir for path.
|
||||
i := len(dirPath)
|
||||
for i > 0 && os.IsPathSeparator(dirPath[i-1]) { // Skip trailing path separator.
|
||||
@@ -71,13 +61,13 @@ func osMkdirAll(dirPath string, perm os.FileMode) error {
|
||||
|
||||
if j > 1 {
|
||||
// Create parent.
|
||||
if err = osMkdirAll(dirPath[:j-1], perm); err != nil {
|
||||
if err := osMkdirAll(dirPath[:j-1], perm); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Parent now exists; invoke Mkdir and use its result.
|
||||
if err = Mkdir(dirPath, perm); err != nil {
|
||||
if err := Mkdir(dirPath, perm); err != nil {
|
||||
if osIsExist(err) {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user