Rewind mode list directory bug fix (#1297)

* rewind bug fix

* adding constant
This commit is contained in:
adfost
2021-12-07 18:01:44 -08:00
committed by GitHub
parent 884321cfce
commit 3db22a2479
2 changed files with 12 additions and 1 deletions

View File

@@ -389,7 +389,7 @@ func computeObjectURLWithoutEncode(bucketName, prefix string) (string, error) {
objectURL = path.Join(objectURL, bucketName)
}
if strings.TrimSpace(prefix) != "" {
objectURL = path.Join(objectURL, prefix)
objectURL = pathJoinFinalSlash(objectURL, prefix)
}
objectURL = fmt.Sprintf("%s://%s", u.Scheme, objectURL)
@@ -418,6 +418,16 @@ func newS3BucketClient(claims *models.Principal, bucketName string, prefix strin
return s3Client, nil
}
// pathJoinFinalSlash - like path.Join() but retains trailing slashSeparator of the last element
func pathJoinFinalSlash(elem ...string) string {
if len(elem) > 0 {
if strings.HasSuffix(elem[len(elem)-1], SlashSeparator) {
return path.Join(elem...) + SlashSeparator
}
}
return path.Join(elem...)
}
// newS3Config simply creates a new Config struct using the passed
// parameters.
func newS3Config(endpoint, accessKey, secretKey, sessionToken string, insecure bool) *mc.Config {

View File

@@ -54,4 +54,5 @@ const (
ConsoleLogQueryURL = "CONSOLE_LOG_QUERY_URL"
ConsoleLogQueryAuthToken = "CONSOLE_LOG_QUERY_AUTH_TOKEN"
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
SlashSeparator = "/"
)