Merge branch 'master' of https://github.com/chrislusf/seaweedfs
This commit is contained in:
@@ -12,11 +12,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const slash = "/"
|
||||||
|
|
||||||
func ParseLocationName(remote string) (locationName string) {
|
func ParseLocationName(remote string) (locationName string) {
|
||||||
if strings.HasSuffix(string(remote), "/") {
|
remote = strings.TrimSuffix(remote, slash)
|
||||||
remote = remote[:len(remote)-1]
|
parts := strings.SplitN(remote, slash, 2)
|
||||||
}
|
|
||||||
parts := strings.SplitN(string(remote), "/", 2)
|
|
||||||
if len(parts) >= 1 {
|
if len(parts) >= 1 {
|
||||||
return parts[0]
|
return parts[0]
|
||||||
}
|
}
|
||||||
@@ -25,35 +25,31 @@ func ParseLocationName(remote string) (locationName string) {
|
|||||||
|
|
||||||
func parseBucketLocation(remote string) (loc *remote_pb.RemoteStorageLocation) {
|
func parseBucketLocation(remote string) (loc *remote_pb.RemoteStorageLocation) {
|
||||||
loc = &remote_pb.RemoteStorageLocation{}
|
loc = &remote_pb.RemoteStorageLocation{}
|
||||||
if strings.HasSuffix(string(remote), "/") {
|
remote = strings.TrimSuffix(remote, slash)
|
||||||
remote = remote[:len(remote)-1]
|
parts := strings.SplitN(remote, slash, 3)
|
||||||
}
|
|
||||||
parts := strings.SplitN(string(remote), "/", 3)
|
|
||||||
if len(parts) >= 1 {
|
if len(parts) >= 1 {
|
||||||
loc.Name = parts[0]
|
loc.Name = parts[0]
|
||||||
}
|
}
|
||||||
if len(parts) >= 2 {
|
if len(parts) >= 2 {
|
||||||
loc.Bucket = parts[1]
|
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 == "" {
|
if loc.Path == "" {
|
||||||
loc.Path = "/"
|
loc.Path = slash
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseNoBucketLocation(remote string) (loc *remote_pb.RemoteStorageLocation) {
|
func parseNoBucketLocation(remote string) (loc *remote_pb.RemoteStorageLocation) {
|
||||||
loc = &remote_pb.RemoteStorageLocation{}
|
loc = &remote_pb.RemoteStorageLocation{}
|
||||||
if strings.HasSuffix(string(remote), "/") {
|
remote = strings.TrimSuffix(remote, slash)
|
||||||
remote = remote[:len(remote)-1]
|
parts := strings.SplitN(remote, slash, 2)
|
||||||
}
|
|
||||||
parts := strings.SplitN(string(remote), "/", 2)
|
|
||||||
if len(parts) >= 1 {
|
if len(parts) >= 1 {
|
||||||
loc.Name = parts[0]
|
loc.Name = parts[0]
|
||||||
}
|
}
|
||||||
loc.Path = string(remote[len(loc.Name):])
|
loc.Path = remote[len(loc.Name):]
|
||||||
if loc.Path == "" {
|
if loc.Path == "" {
|
||||||
loc.Path = "/"
|
loc.Path = slash
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)
|
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
w.Header().Set("Location", "/" + bucket)
|
||||||
writeSuccessResponseEmpty(w, r)
|
writeSuccessResponseEmpty(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user