fix case where bucket directory is created without acl

This commit is contained in:
Ben McClelland
2023-06-19 10:34:45 -07:00
parent d2eab5bce3
commit 33673de160
2 changed files with 11 additions and 0 deletions

View File

@@ -46,6 +46,10 @@ type AccessControlList struct {
}
func ParseACL(data []byte) (ACL, error) {
if len(data) == 0 {
return ACL{}, nil
}
var acl ACL
if err := json.Unmarshal(data, &acl); err != nil {
return acl, fmt.Errorf("parse acl: %w", err)

View File

@@ -834,11 +834,15 @@ func (p *Posix) removeParents(bucket, object string) error {
parent := filepath.Dir(objPath)
if filepath.Base(parent) == bucket {
// stop removing parents if we hit the bucket directory.
break
}
_, err := xattr.Get(parent, etagkey)
if err == nil {
// a directory with a valid etag means this was specifically
// uploaded with a put object, so stop here and leave this
// directory in place.
break
}
@@ -1124,6 +1128,9 @@ func (p *Posix) GetBucketAcl(bucket string) ([]byte, error) {
}
b, err := xattr.Get(bucket, aclkey)
if isNoAttr(err) {
return []byte{}, nil
}
if err != nil {
return nil, fmt.Errorf("get acl: %w", err)
}