mirror of https://github.com/minio/minio.git
Merge pull request #917 from harshavardhana/fs-separator
Add fs separator
This commit is contained in:
commit
357f9d7a05
|
@ -131,9 +131,13 @@ func IgnoreResourcesHandler(h http.Handler) http.Handler {
|
|||
return resourceHandler{h}
|
||||
}
|
||||
|
||||
const (
|
||||
separator = "/"
|
||||
)
|
||||
|
||||
// Resource handler ServeHTTP() wrapper
|
||||
func (h resourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
splits := strings.SplitN(r.URL.Path, "/", 3)
|
||||
splits := strings.SplitN(r.URL.Path, separator, 3)
|
||||
switch len(splits) {
|
||||
// bucket exists
|
||||
case 2:
|
||||
|
|
|
@ -118,9 +118,9 @@ func getMetadata(rootPath, bucket, object string) (ObjectMetadata, *probe.Error)
|
|||
// in a static manner so that we can send a proper 'ObjectNotFound' reply back upon os.Stat()
|
||||
var objectPath string
|
||||
if runtime.GOOS == "windows" {
|
||||
objectPath = rootPath + "\\" + bucket + "\\" + object
|
||||
objectPath = rootPath + string(os.PathSeparator) + bucket + string(os.PathSeparator) + object
|
||||
} else {
|
||||
objectPath = rootPath + "/" + bucket + "/" + object
|
||||
objectPath = rootPath + string(os.PathSeparator) + bucket + string(os.PathSeparator) + object
|
||||
}
|
||||
stat, err := os.Stat(objectPath)
|
||||
if err != nil {
|
||||
|
@ -275,9 +275,9 @@ func (fs API) DeleteObject(bucket, object string) *probe.Error {
|
|||
// in a static manner so that we can send a proper 'ObjectNotFound' reply back upon os.Stat()
|
||||
var objectPath string
|
||||
if runtime.GOOS == "windows" {
|
||||
objectPath = fs.path + "\\" + bucket + "\\" + object
|
||||
objectPath = fs.path + string(os.PathSeparator) + bucket + string(os.PathSeparator) + object
|
||||
} else {
|
||||
objectPath = fs.path + "/" + bucket + "/" + object
|
||||
objectPath = fs.path + string(os.PathSeparator) + bucket + string(os.PathSeparator) + object
|
||||
}
|
||||
|
||||
_, err := os.Stat(objectPath)
|
||||
|
|
10
pkg/fs/fs.go
10
pkg/fs/fs.go
|
@ -260,7 +260,7 @@ func (fs API) ListObjects(bucket string, resources BucketResourcesMetadata) ([]O
|
|||
/// automatically treat "/" delimiter as "\\" delimiter on windows due to its path constraints.
|
||||
if resources.Delimiter == "/" {
|
||||
if runtime.GOOS == "windows" {
|
||||
resources.Delimiter = "\\"
|
||||
resources.Delimiter = string(os.PathSeparator)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,11 +344,11 @@ func (fs API) ListObjects(bucket string, resources BucketResourcesMetadata) ([]O
|
|||
// Split the root prefix from the incoming file pointer
|
||||
realFp := ""
|
||||
if runtime.GOOS == "windows" {
|
||||
if splits := strings.Split(fp, p.root+"\\"); len(splits) > 1 {
|
||||
if splits := strings.Split(fp, (p.root + string(os.PathSeparator))); len(splits) > 1 {
|
||||
realFp = splits[1]
|
||||
}
|
||||
} else {
|
||||
if splits := strings.Split(fp, p.root+"/"); len(splits) > 1 {
|
||||
if splits := strings.Split(fp, (p.root + string(os.PathSeparator))); len(splits) > 1 {
|
||||
realFp = splits[1]
|
||||
}
|
||||
}
|
||||
|
@ -367,11 +367,11 @@ func (fs API) ListObjects(bucket string, resources BucketResourcesMetadata) ([]O
|
|||
if resources.Marker != "" {
|
||||
if realFp != "" {
|
||||
if runtime.GOOS == "windows" {
|
||||
if realFp < strings.Split(resources.Marker, "\\")[0] {
|
||||
if realFp < strings.Split(resources.Marker, string(os.PathSeparator))[0] {
|
||||
return ErrSkipDir
|
||||
}
|
||||
} else {
|
||||
if realFp < strings.Split(resources.Marker, "/")[0] {
|
||||
if realFp < strings.Split(resources.Marker, string(os.PathSeparator))[0] {
|
||||
return ErrSkipDir
|
||||
}
|
||||
}
|
||||
|
|
|
@ -489,7 +489,6 @@ func (s *MyAPIFSCacheSuite) TestNotImplemented(c *C) {
|
|||
response, err := client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(response.StatusCode, Equals, http.StatusNotImplemented)
|
||||
|
||||
}
|
||||
|
||||
func (s *MyAPIFSCacheSuite) TestHeader(c *C) {
|
||||
|
|
Loading…
Reference in New Issue