From 2062add05f306841c1d681c40206fa64568c1fa0 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 12 Dec 2016 15:43:41 -0800 Subject: [PATCH] fs/posix: On windows use helpers and init format.json properly. (#3434) Fixes #3433 --- cmd/posix.go | 8 ++++---- cmd/prepare-storage.go | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/posix.go b/cmd/posix.go index 83673c465..230d43048 100644 --- a/cmd/posix.go +++ b/cmd/posix.go @@ -73,7 +73,7 @@ func checkPathLength(pathName string) error { // isDirEmpty - returns whether given directory is empty or not. func isDirEmpty(dirname string) bool { - f, err := os.Open(dirname) + f, err := os.Open(preparePath(dirname)) if err != nil { errorIf(func() error { if !os.IsNotExist(err) { @@ -129,7 +129,7 @@ func newPosix(path string) (StorageAPI, error) { } if os.IsNotExist(err) { // Disk not found create it. - err = os.MkdirAll(preparePath(diskPath), 0777) + err = mkdirAll(diskPath, 0777) if err != nil { return nil, err } @@ -625,7 +625,7 @@ func (s *posix) createFile(volume, path string) (f *os.File, err error) { } else { // Create top level directories if they don't exist. // with mode 0777 mkdir honors system umask. - if err = mkdirAll(preparePath(slashpath.Dir(filePath)), 0777); err != nil { + if err = mkdirAll(slashpath.Dir(filePath), 0777); err != nil { // File path cannot be verified since one of the parents is a file. if isSysErrNotDir(err) { return nil, errFileAccessDenied @@ -935,7 +935,7 @@ func (s *posix) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) (err e // Destination does not exist, hence proceed with the rename. } // Creates all the parent directories, with mode 0777 mkdir honors system umask. - if err = mkdirAll(preparePath(slashpath.Dir(dstFilePath)), 0777); err != nil { + if err = mkdirAll(slashpath.Dir(dstFilePath), 0777); err != nil { // File path cannot be verified since one of the parents is a file. if isSysErrNotDir(err) { return errFileAccessDenied diff --git a/cmd/prepare-storage.go b/cmd/prepare-storage.go index df72006c7..aebf8bc0a 100644 --- a/cmd/prepare-storage.go +++ b/cmd/prepare-storage.go @@ -223,7 +223,8 @@ func retryFormattingDisks(firstDisk bool, endpoints []*url.URL, storageDisks []S if len(formatConfigs) == 1 { err := genericFormatCheckFS(formatConfigs[0], sErrs[0]) if err != nil { - if err == errUnformattedDisk { + // For an new directory or existing data. + if err == errUnformattedDisk || err == errCorruptedFormat { return initFormatFS(storageDisks[0]) } return err