@ -12,7 +12,6 @@ import (
"io"
"io"
"net/http"
"net/http"
"net/url"
"net/url"
"sort"
"strconv"
"strconv"
"strings"
"strings"
)
)
@ -193,20 +192,26 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
if delimiter == "/" {
if delimiter == "/" {
if entry . IsDirectoryKeyObject ( ) {
if entry . IsDirectoryKeyObject ( ) {
// glog.V(0).Infof("append IsDirectoryKeyObject %s", key+"/")
// glog.V(0).Infof("append IsDirectoryKeyObject %s", key+"/")
contents = append ( contents , newListEntry ( entry , key + "/" , "" , "" , bucketPrefix , fetchOwner , false ) )
contents = append ( contents , newListEntry ( entry , key + "/" , "" , "" , bucketPrefix , fetchOwner , false , encodingTypeUrl ) )
cursor . maxKeys --
cursor . maxKeys --
return
return
}
}
if entry . IsDirectory {
if entry . IsDirectory {
// glog.V(0).Infof("append commonPrefixes %s", key+"/")
// glog.V(0).Infof("append commonPrefixes %s", key+"/")
var prefixKey string
if encodingTypeUrl {
prefixKey = urlPathEscape ( key + "/" )
} else {
prefixKey = key + "/"
}
commonPrefixes = append ( commonPrefixes , PrefixEntry {
commonPrefixes = append ( commonPrefixes , PrefixEntry {
Prefix : key + "/" ,
Prefix : prefixKey ,
} )
} )
cursor . maxKeys --
cursor . maxKeys --
return
return
}
}
}
}
contents = append ( contents , newListEntry ( entry , key , "" , "" , bucketPrefix , fetchOwner , false ) )
contents = append ( contents , newListEntry ( entry , key , "" , "" , bucketPrefix , fetchOwner , false , encodingTypeUrl ) )
cursor . maxKeys --
cursor . maxKeys --
} ,
} ,
)
)
@ -229,7 +234,7 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
dirName , entryName , prefixName := entryUrlEncode ( dir , entry . Name , encodingTypeUrl )
dirName , entryName , prefixName := entryUrlEncode ( dir , entry . Name , encodingTypeUrl )
if entry . IsDirectory {
if entry . IsDirectory {
if entry . IsDirectoryKeyObject ( ) {
if entry . IsDirectoryKeyObject ( ) {
contents = append ( contents , newListEntry ( entry , "" , dirName , entryName , bucketPrefix , fetchOwner , true ) )
contents = append ( contents , newListEntry ( entry , "" , dirName , entryName , bucketPrefix , fetchOwner , true , false ) )
cursor . maxKeys --
cursor . maxKeys --
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
// 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.
} else if delimiter == "/" { // A response can contain CommonPrefixes only if you specify a delimiter.
@ -272,7 +277,7 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
}
}
}
}
if ! delimiterFound {
if ! delimiterFound {
contents = append ( contents , newListEntry ( entry , "" , dirName , entryName , bucketPrefix , fetchOwner , false ) )
contents = append ( contents , newListEntry ( entry , "" , dirName , entryName , bucketPrefix , fetchOwner , false , false ) )
cursor . maxKeys --
cursor . maxKeys --
}
}
}
}
@ -307,9 +312,8 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
CommonPrefixes : commonPrefixes ,
CommonPrefixes : commonPrefixes ,
}
}
if encodingTypeUrl {
if encodingTypeUrl {
sort . Slice ( response . CommonPrefixes , func ( i , j int ) bool {
return response . CommonPrefixes [ i ] . Prefix < response . CommonPrefixes [ j ] . Prefix
} )
// Todo used for pass test_bucket_listv2_encoding_basic
// sort.Slice(response.CommonPrefixes, func(i, j int) bool { return response.CommonPrefixes[i].Prefix < response.CommonPrefixes[j].Prefix })
response . EncodingType = s3 . EncodingTypeUrl
response . EncodingType = s3 . EncodingTypeUrl
}
}
return nil
return nil