mirror of
https://github.com/versity/versitygw.git
synced 2026-01-07 04:06:23 +00:00
fix: azure list objects trim common prefixes that match marker prefix
This commit is contained in:
@@ -567,14 +567,19 @@ Pager:
|
||||
isTruncated = true
|
||||
break Pager
|
||||
}
|
||||
|
||||
marker := getString(input.Marker)
|
||||
pfx := strings.TrimSuffix(*v.Name, getString(input.Delimiter))
|
||||
if marker != "" && strings.HasPrefix(marker, pfx) {
|
||||
continue
|
||||
}
|
||||
|
||||
cPrefixes = append(cPrefixes, types.CommonPrefix{
|
||||
Prefix: v.Name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: generate common prefixes when appropriate
|
||||
|
||||
return s3response.ListObjectsResult{
|
||||
Contents: objects,
|
||||
Marker: input.Marker,
|
||||
@@ -644,6 +649,13 @@ Pager:
|
||||
isTruncated = true
|
||||
break Pager
|
||||
}
|
||||
|
||||
marker := getString(input.ContinuationToken)
|
||||
pfx := strings.TrimSuffix(*v.Name, getString(input.Delimiter))
|
||||
if marker != "" && strings.HasPrefix(marker, pfx) {
|
||||
continue
|
||||
}
|
||||
|
||||
cPrefixes = append(cPrefixes, types.CommonPrefix{
|
||||
Prefix: v.Name,
|
||||
})
|
||||
|
||||
@@ -3605,12 +3605,12 @@ func ListObjects_paginated(s *S3Conf) error {
|
||||
|
||||
expected := []string{"dir1/subdir.ext", "dir1/subdir1.ext", "dir1/subdir2.ext"}
|
||||
if !hasObjNames(objs, expected) {
|
||||
return fmt.Errorf("expected objects %v, instead got %v", expected, objs)
|
||||
return fmt.Errorf("expected objects %v, instead got %v", expected, objStrings(objs))
|
||||
}
|
||||
|
||||
expectedPrefix := []string{"dir1/subdir/"}
|
||||
if !hasPrefixName(prefixes, expectedPrefix) {
|
||||
return fmt.Errorf("expected prefixes %v, instead got %v", expectedPrefix, prefixes)
|
||||
return fmt.Errorf("expected prefixes %v, instead got %v", expectedPrefix, pfxStrings(prefixes))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -844,3 +844,19 @@ func checkWORMProtection(client *s3.Client, bucket, object string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func objStrings(objs []types.Object) []string {
|
||||
objStrs := make([]string, len(objs))
|
||||
for i, obj := range objs {
|
||||
objStrs[i] = *obj.Key
|
||||
}
|
||||
return objStrs
|
||||
}
|
||||
|
||||
func pfxStrings(pfxs []types.CommonPrefix) []string {
|
||||
pfxStrs := make([]string, len(pfxs))
|
||||
for i, pfx := range pfxs {
|
||||
pfxStrs[i] = *pfx.Prefix
|
||||
}
|
||||
return pfxStrs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user