aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-04-06 00:28:51 -0700
committerchrislu <chris.lu@gmail.com>2022-04-06 00:28:51 -0700
commit3d229fe45c66d79ea95a82a0a57d53ffaf3cd5e1 (patch)
tree82cbdea88ceee947728b4643f20a415eb4d67589
parent79b8e6a8c31d20b309f3ffe67fb37701054d6000 (diff)
parent49ecb8d11c9d11d67583356bdd8896a7f97252a3 (diff)
downloadseaweedfs-3d229fe45c66d79ea95a82a0a57d53ffaf3cd5e1.tar.xz
seaweedfs-3d229fe45c66d79ea95a82a0a57d53ffaf3cd5e1.zip
Merge branch 'master' of https://github.com/chrislusf/seaweedfs
-rw-r--r--weed/remote_storage/remote_storage.go28
-rw-r--r--weed/s3api/s3api_bucket_handlers.go1
2 files changed, 13 insertions, 16 deletions
diff --git a/weed/remote_storage/remote_storage.go b/weed/remote_storage/remote_storage.go
index d8d1e1f5c..e4a027199 100644
--- a/weed/remote_storage/remote_storage.go
+++ b/weed/remote_storage/remote_storage.go
@@ -12,11 +12,11 @@ import (
"time"
)
+const slash = "/"
+
func ParseLocationName(remote string) (locationName string) {
- if strings.HasSuffix(string(remote), "/") {
- remote = remote[:len(remote)-1]
- }
- parts := strings.SplitN(string(remote), "/", 2)
+ remote = strings.TrimSuffix(remote, slash)
+ parts := strings.SplitN(remote, slash, 2)
if len(parts) >= 1 {
return parts[0]
}
@@ -25,35 +25,31 @@ func ParseLocationName(remote string) (locationName string) {
func parseBucketLocation(remote string) (loc *remote_pb.RemoteStorageLocation) {
loc = &remote_pb.RemoteStorageLocation{}
- if strings.HasSuffix(string(remote), "/") {
- remote = remote[:len(remote)-1]
- }
- parts := strings.SplitN(string(remote), "/", 3)
+ remote = strings.TrimSuffix(remote, slash)
+ parts := strings.SplitN(remote, slash, 3)
if len(parts) >= 1 {
loc.Name = parts[0]
}
if len(parts) >= 2 {
loc.Bucket = parts[1]
}
- loc.Path = string(remote[len(loc.Name)+1+len(loc.Bucket):])
+ loc.Path = remote[len(loc.Name)+1+len(loc.Bucket):]
if loc.Path == "" {
- loc.Path = "/"
+ loc.Path = slash
}
return
}
func parseNoBucketLocation(remote string) (loc *remote_pb.RemoteStorageLocation) {
loc = &remote_pb.RemoteStorageLocation{}
- if strings.HasSuffix(string(remote), "/") {
- remote = remote[:len(remote)-1]
- }
- parts := strings.SplitN(string(remote), "/", 2)
+ remote = strings.TrimSuffix(remote, slash)
+ parts := strings.SplitN(remote, slash, 2)
if len(parts) >= 1 {
loc.Name = parts[0]
}
- loc.Path = string(remote[len(loc.Name):])
+ loc.Path = remote[len(loc.Name):]
if loc.Path == "" {
- loc.Path = "/"
+ loc.Path = slash
}
return
}
diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go
index b8f2c2f7a..7de1d5ebb 100644
--- a/weed/s3api/s3api_bucket_handlers.go
+++ b/weed/s3api/s3api_bucket_handlers.go
@@ -135,6 +135,7 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request)
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)
return
}
+ w.Header().Set("Location", "/" + bucket)
writeSuccessResponseEmpty(w, r)
}