@ -142,7 +142,7 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
var nextMarker string
cursor := & ListingCursor {
maxKeys : maxKeys ,
prefixEndsOnDelimiter : strings . HasSuffix ( originalPrefix , "/" ) ,
prefixEndsOnDelimiter : strings . HasSuffix ( originalPrefix , "/" ) && len ( originalMarker ) == 0 ,
}
// check filer
@ -152,14 +152,7 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
nextMarker , doErr = s3a . doListFilerEntries ( client , reqDir , prefix , cursor , marker , delimiter , false , func ( dir string , entry * filer_pb . Entry ) {
empty = false
if entry . IsDirectory {
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
if delimiter == "/" { // A response can contain CommonPrefixes only if you specify a delimiter.
commonPrefixes = append ( commonPrefixes , PrefixEntry {
Prefix : fmt . Sprintf ( "%s/%s/" , dir , entry . Name ) [ len ( bucketPrefix ) : ] ,
} )
//All of the keys (up to 1,000) rolled up into a common prefix count as a single return when calculating the number of returns.
cursor . maxKeys --
} else if entry . IsDirectoryKeyObject ( ) {
if entry . IsDirectoryKeyObject ( ) {
contents = append ( contents , ListEntry {
Key : fmt . Sprintf ( "%s/%s/" , dir , entry . Name ) [ len ( bucketPrefix ) : ] ,
LastModified : time . Unix ( entry . Attributes . Mtime , 0 ) . UTC ( ) ,
@ -171,6 +164,13 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
StorageClass : "STANDARD" ,
} )
cursor . maxKeys --
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
} else if delimiter == "/" { // A response can contain CommonPrefixes only if you specify a delimiter.
commonPrefixes = append ( commonPrefixes , PrefixEntry {
Prefix : fmt . Sprintf ( "%s/%s/" , dir , entry . Name ) [ len ( bucketPrefix ) : ] ,
} )
//All of the keys (up to 1,000) rolled up into a common prefix count as a single return when calculating the number of returns.
cursor . maxKeys --
}
} else {
storageClass := "STANDARD"
@ -238,7 +238,11 @@ type ListingCursor struct {
func normalizePrefixMarker ( prefix , marker string ) ( alignedDir , alignedPrefix , alignedMarker string ) {
// alignedDir should not end with "/"
// alignedDir, alignedPrefix, alignedMarker should only have "/" in middle
if len ( marker ) == 0 {
prefix = strings . Trim ( prefix , "/" )
} else {
prefix = strings . TrimLeft ( prefix , "/" )
}
marker = strings . TrimLeft ( marker , "/" )
if prefix == "" {
return "" , "" , marker
@ -368,6 +372,9 @@ func (s3a *S3ApiServer) doListFilerEntries(client filer_pb.SeaweedFilerClient, d
if delimiter != "/" || cursor . prefixEndsOnDelimiter {
if cursor . prefixEndsOnDelimiter {
cursor . prefixEndsOnDelimiter = false
if entry . IsDirectoryKeyObject ( ) {
eachEntryFn ( dir , entry )
}
} else {
eachEntryFn ( dir , entry )
}