fix: extend parentDirIsObject for all parents

This commit is contained in:
Harshavardhana 2021-07-30 09:20:40 -07:00
parent 83ed1f361b
commit 0a276a25cf

View file

@ -24,6 +24,7 @@ import (
"io"
"math/rand"
"net/http"
"path"
"sort"
"sync"
"time"
@ -755,7 +756,19 @@ func (s *erasureSets) GetObject(ctx context.Context, bucket, object string, star
}
func (s *erasureSets) parentDirIsObject(ctx context.Context, bucket, parent string) bool {
return s.getHashedSet(parent).parentDirIsObject(ctx, bucket, parent)
var isParentDirObject func(string) bool
isParentDirObject = func(p string) bool {
if p == "." || p == SlashSeparator {
return false
}
if s.getHashedSet(p).isObject(ctx, bucket, p) {
// If there is already a file at prefix "p", return true.
return true
}
// Check if there is a file as one of the parent paths.
return isParentDirObject(path.Dir(p))
}
return isParentDirObject(parent)
}
// PutObject - writes an object to hashedSet based on the object name.