diff --git a/bucket-handlers.go b/bucket-handlers.go index 7cf1f66fd..3dd3e52a3 100644 --- a/bucket-handlers.go +++ b/bucket-handlers.go @@ -594,9 +594,9 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h } encodedSuccessResponse := encodeResponse(PostResponse{ Location: getObjectLocation(bucket, object), // TODO Full URL is preferred - Bucket: bucket, - Key: object, - ETag: md5Sum, + Bucket: bucket, + Key: object, + ETag: md5Sum, }) setCommonHeaders(w) writeSuccessResponse(w, encodedSuccessResponse) diff --git a/posix-dir-common.go b/posix-dir-common.go index 008a5d541..933399ac5 100644 --- a/posix-dir-common.go +++ b/posix-dir-common.go @@ -108,10 +108,9 @@ func treeWalk(bucketDir, prefixDir, entryPrefixMatch, marker string, recursive b fileInfo.Mode = dirent.mode } if fileInfo.Mode.IsDir() { - // Add os.PathSeparator suffix again for directories as - // filepath.Join would have removed it. + // Add "/" suffix again for directories as fileInfo.Size = 0 - fileInfo.Name += string(os.PathSeparator) + fileInfo.Name += "/" } return fileInfo, nil } diff --git a/posix-dir-nix.go b/posix-dir-nix.go index 78de6be5a..17c748b75 100644 --- a/posix-dir-nix.go +++ b/posix-dir-nix.go @@ -132,7 +132,7 @@ func scandir(dirPath string, filter func(fsDirent) bool, namesOnly bool) ([]fsDi dirent.name = path.Join(dirPath, dirent.name) } if dirent.IsDir() { - dirent.name += string(os.PathSeparator) + dirent.name += "/" dirent.size = 0 } if filter == nil || filter(dirent) { diff --git a/posix.go b/posix.go index 98973bdef..d177e3c29 100644 --- a/posix.go +++ b/posix.go @@ -33,7 +33,7 @@ import ( ) const ( - fsListLimit = 1000 + fsListLimit = 1000 fsMinSpacePercent = 5 ) @@ -160,7 +160,7 @@ func removeDuplicateVols(volsInfo []VolInfo) []VolInfo { func getAllUniqueVols(dirPath string) ([]VolInfo, error) { volumeFn := func(dirent fsDirent) bool { // Return all directories. - return dirent.IsDir() && isValidVolname(filepath.Clean(dirent.name)) + return dirent.IsDir() && isValidVolname(path.Clean(dirent.name)) } namesOnly := true // Returned are only names. dirents, err := scandir(dirPath, volumeFn, namesOnly) @@ -173,10 +173,10 @@ func getAllUniqueVols(dirPath string) ([]VolInfo, error) { } var volsInfo []VolInfo for _, dirent := range dirents { - fi, err := os.Stat(filepath.Join(dirPath, dirent.name)) + fi, err := os.Stat(pathJoin(dirPath, dirent.name)) if err != nil { log.WithFields(logrus.Fields{ - "path": filepath.Join(dirPath, dirent.name), + "path": pathJoin(dirPath, dirent.name), }).Debugf("Stat failed with error %s", err) return nil, err } @@ -198,7 +198,7 @@ func (s fsStorage) getVolumeDir(volume string) (string, error) { if !isValidVolname(volume) { return "", errInvalidArgument } - volumeDir := filepath.Join(s.diskPath, volume) + volumeDir := pathJoin(s.diskPath, volume) _, err := os.Stat(volumeDir) if err == nil { return volumeDir, nil @@ -210,12 +210,10 @@ func (s fsStorage) getVolumeDir(volume string) (string, error) { return volumeDir, errVolumeNotFound } for _, vol := range volsInfo { - // Verify if lowercase version of - // the volume - // is equal to the incoming volume, then use the proper - // name. + // Verify if lowercase version of the volume is equal to + // the incoming volume, then use the proper name. if strings.ToLower(vol.Name) == volume { - volumeDir = filepath.Join(s.diskPath, vol.Name) + volumeDir = pathJoin(s.diskPath, vol.Name) return volumeDir, nil } } @@ -544,7 +542,7 @@ func (s fsStorage) ReadFile(volume string, path string, offset int64) (readClose return nil, err } - filePath := filepath.Join(volumeDir, filepath.FromSlash(path)) + filePath := pathJoin(volumeDir, path) file, err := os.Open(filePath) if err != nil { if os.IsNotExist(err) { @@ -600,7 +598,7 @@ func (s fsStorage) CreateFile(volume, path string) (writeCloser io.WriteCloser, if err = checkDiskFree(s.diskPath, s.minFreeDisk); err != nil { return nil, err } - filePath := filepath.Join(volumeDir, path) + filePath := pathJoin(volumeDir, path) // Verify if the file already exists and is not of regular type. var st os.FileInfo if st, err = os.Stat(filePath); err == nil { @@ -634,7 +632,7 @@ func (s fsStorage) StatFile(volume, path string) (file FileInfo, err error) { return FileInfo{}, err } - filePath := filepath.Join(volumeDir, filepath.FromSlash(path)) + filePath := pathJoin(volumeDir, path) st, err := os.Stat(filePath) if err != nil { log.WithFields(logrus.Fields{ @@ -712,10 +710,10 @@ func deleteFile(basePath, deletePath string) error { return err } // Recursively go down the next path and delete again. - if err := deleteFile(basePath, filepath.Dir(deletePath)); err != nil { + if err := deleteFile(basePath, path.Dir(deletePath)); err != nil { log.WithFields(logrus.Fields{ "basePath": basePath, - "deleteDir": filepath.Dir(deletePath), + "deleteDir": path.Dir(deletePath), }).Debugf("deleteFile failed with %s", err) return err } @@ -735,10 +733,7 @@ func (s fsStorage) DeleteFile(volume, path string) error { // Following code is needed so that we retain "/" suffix if any in // path argument. - filePath := filepath.Join(volumeDir, filepath.FromSlash(path)) - if strings.HasSuffix(filepath.FromSlash(path), string(os.PathSeparator)) { - filePath = filePath + string(os.PathSeparator) - } + filePath := pathJoin(volumeDir, path) // Delete file and delete parent directory as well if its empty. return deleteFile(volumeDir, filePath) diff --git a/xl-erasure-v1-common.go b/xl-erasure-v1-common.go index 2973a1232..39987078f 100644 --- a/xl-erasure-v1-common.go +++ b/xl-erasure-v1-common.go @@ -19,7 +19,6 @@ package main import ( "errors" slashpath "path" - "path/filepath" "github.com/Sirupsen/logrus" ) @@ -145,8 +144,8 @@ func (xl XL) getPartsMetadata(volume, path string) ([]xlMetaV1, []error) { // Returns collection of errors, indexed in accordance with input // updateParts order. // Write lockNS() should be done by caller. -func (xl XL) setPartsMetadata(volume, path string, metadata xlMetaV1, updateParts []bool) []error { - xlMetaV1FilePath := filepath.Join(path, xlMetaV1File) +func (xl XL) updatePartsMetadata(volume, path string, metadata xlMetaV1, updateParts []bool) []error { + xlMetaV1FilePath := pathJoin(path, xlMetaV1File) errs := make([]error, len(xl.storageDisks)) for index := range updateParts { diff --git a/xl-erasure-v1-healfile.go b/xl-erasure-v1-healfile.go index be9933e6a..ee2f37ee4 100644 --- a/xl-erasure-v1-healfile.go +++ b/xl-erasure-v1-healfile.go @@ -206,8 +206,8 @@ func (xl XL) healFile(volume string, path string) error { writer.Close() } - // Update the quorum metadata after selfheal. - errs := xl.setPartsMetadata(volume, path, metadata, needsHeal) + // Update the quorum metadata after heal. + errs := xl.updatePartsMetadata(volume, path, metadata, needsHeal) for index, healNeeded := range needsHeal { if healNeeded && errs[index] != nil { return errs[index]