Remove go1.9 specific code for windows (#5033)

Following fix https://go-review.googlesource.com/#/c/41834/ has
been merged upstream and released with go1.9.
This commit is contained in:
Harshavardhana
2017-10-13 03:01:15 -07:00
committed by Nitish Tiwari
parent ad53c5d859
commit 3d0dced23c
21 changed files with 52 additions and 610 deletions

View File

@@ -46,7 +46,7 @@ func TestServerConfigMigrateV1(t *testing.T) {
t.Fatal("Unexpected error: ", err)
}
// Check if config v1 is removed from filesystem
if _, err := osStat(configPath); err == nil || !os.IsNotExist(err) {
if _, err := os.Stat(configPath); err == nil || !os.IsNotExist(err) {
t.Fatal("Config V1 file is not purged")
}

View File

@@ -133,7 +133,7 @@ func fsStat(statLoc string) (os.FileInfo, error) {
if err := checkPathLength(statLoc); err != nil {
return nil, traceError(err)
}
fi, err := osStat((statLoc))
fi, err := os.Stat((statLoc))
if err != nil {
return nil, traceError(err)
}
@@ -211,7 +211,7 @@ func fsOpenFile(readPath string, offset int64) (io.ReadCloser, int64, error) {
}
// Stat to get the size of the file at path.
st, err := osStat((readPath))
st, err := os.Stat((readPath))
if err != nil {
return nil, 0, traceError(err)
}

View File

@@ -538,11 +538,11 @@ func TestFSRemoveMeta(t *testing.T) {
t.Fatalf("Unable to remove file, %s", err)
}
if _, err := osStat((filePath)); !os.IsNotExist(err) {
if _, err := os.Stat((filePath)); !os.IsNotExist(err) {
t.Fatalf("`%s` file found though it should have been deleted.", filePath)
}
if _, err := osStat((path.Dir(filePath))); !os.IsNotExist(err) {
if _, err := os.Stat((path.Dir(filePath))); !os.IsNotExist(err) {
t.Fatalf("`%s` parent directory found though it should have been deleted.", filePath)
}
}

View File

@@ -86,7 +86,7 @@ func newFSObjectLayer(fsPath string) (ObjectLayer, error) {
return nil, err
}
fi, err := osStat((fsPath))
fi, err := os.Stat((fsPath))
if err == nil {
if !fi.IsDir() {
return nil, syscall.ENOTDIR
@@ -230,7 +230,7 @@ func (fs fsObjects) GetBucketInfo(bucket string) (bi BucketInfo, e error) {
return bi, toObjectErr(err, bucket)
}
// As osStat() doesn't carry other than ModTime(), use ModTime() as CreatedTime.
// As os.Stat() doesn't carry other than ModTime(), use ModTime() as CreatedTime.
createdTime := st.ModTime()
return BucketInfo{
Name: bucket,
@@ -266,7 +266,7 @@ func (fs fsObjects) ListBuckets() ([]BucketInfo, error) {
}
bucketInfos = append(bucketInfos, BucketInfo{
Name: fi.Name(),
// As osStat() doesnt carry CreatedTime, use ModTime() as CreatedTime.
// As os.Stat() doesnt carry CreatedTime, use ModTime() as CreatedTime.
Created: fi.ModTime(),
})
}

View File

@@ -22,9 +22,10 @@ import (
"sync"
"fmt"
"time"
"github.com/minio/dsync"
"github.com/minio/lsync"
"time"
)
// Global name space lock.

View File

@@ -75,12 +75,12 @@ func parseDirents(dirPath string, buf []byte) (entries []string, err error) {
case syscall.DT_REG:
entries = append(entries, name)
case syscall.DT_LNK, syscall.DT_UNKNOWN:
// If its symbolic link, follow the link using osStat()
// If its symbolic link, follow the link using os.Stat()
// On Linux XFS does not implement d_type for on disk
// format << v5. Fall back to OsStat().
var fi os.FileInfo
fi, err = osStat(path.Join(dirPath, name))
fi, err = os.Stat(path.Join(dirPath, name))
if err != nil {
// If file does not exist, we continue and skip it.
// Could happen if it was deleted in the middle while

View File

@@ -55,7 +55,7 @@ func readDir(dirPath string) (entries []string, err error) {
// Stat symbolic link and follow to get the final value.
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
var st os.FileInfo
st, err = osStat((path.Join(dirPath, fi.Name())))
st, err = os.Stat((path.Join(dirPath, fi.Name())))
if err != nil {
errorIf(err, "Unable to stat path %s", path.Join(dirPath, fi.Name()))
continue

View File

@@ -18,14 +18,6 @@
package cmd
import "os"
// osStat returns a FileInfo structure describing the named file.
// If there is an error, it will be of type *PathError.
func osStat(name string) (os.FileInfo, error) {
return os.Stat(name)
}
// isValidVolname verifies a volname name in accordance with object
// layer requirements.
func isValidVolname(volname string) bool {

View File

@@ -62,7 +62,7 @@ func TestIsValidUmaskVol(t *testing.T) {
defer os.RemoveAll(tmpPath)
// Stat to get permissions bits.
st, err := osStat(path.Join(tmpPath, testCase.volName))
st, err := os.Stat(path.Join(tmpPath, testCase.volName))
if err != nil {
t.Fatalf("Stat failed with %s expected to pass.", err)
}

View File

@@ -19,17 +19,9 @@
package cmd
import (
"os"
"strings"
os2 "github.com/minio/minio/pkg/x/os"
)
// Wrapper around safe stat implementation to avoid windows bugs.
func osStat(name string) (os.FileInfo, error) {
return os2.Stat(name)
}
// isValidVolname verifies a volname name in accordance with object
// layer requirements.
func isValidVolname(volname string) bool {

View File

@@ -113,7 +113,7 @@ func newPosix(path string) (StorageAPI, error) {
},
},
}
fi, err := osStat((diskPath))
fi, err := os.Stat((diskPath))
if err == nil {
if !fi.IsDir() {
return nil, syscall.ENOTDIR
@@ -249,7 +249,7 @@ func (s *posix) getVolDir(volume string) (string, error) {
// checkDiskFound - validates if disk is available,
// returns errDiskNotFound if not found.
func (s *posix) checkDiskFound() (err error) {
_, err = osStat((s.diskPath))
_, err = os.Stat((s.diskPath))
if err != nil {
if os.IsNotExist(err) {
return errDiskNotFound
@@ -340,7 +340,7 @@ func listVols(dirPath string) ([]VolInfo, error) {
continue
}
var fi os.FileInfo
fi, err = osStat((pathJoin(dirPath, entry)))
fi, err = os.Stat((pathJoin(dirPath, entry)))
if err != nil {
// If the file does not exist, skip the entry.
if os.IsNotExist(err) {
@@ -350,7 +350,7 @@ func listVols(dirPath string) ([]VolInfo, error) {
}
volsInfo = append(volsInfo, VolInfo{
Name: fi.Name(),
// As osStat() doesn't carry other than ModTime(), use
// As os.Stat() doesn't carry other than ModTime(), use
// ModTime() as CreatedTime.
Created: fi.ModTime(),
})
@@ -381,14 +381,14 @@ func (s *posix) StatVol(volume string) (volInfo VolInfo, err error) {
}
// Stat a volume entry.
var st os.FileInfo
st, err = osStat((volumeDir))
st, err = os.Stat((volumeDir))
if err != nil {
if os.IsNotExist(err) {
return VolInfo{}, errVolumeNotFound
}
return VolInfo{}, err
}
// As osStat() doesn't carry other than ModTime(), use ModTime()
// As os.Stat() doesn't carry other than ModTime(), use ModTime()
// as CreatedTime.
createdTime := st.ModTime()
return VolInfo{
@@ -453,7 +453,7 @@ func (s *posix) ListDir(volume, dirPath string) (entries []string, err error) {
return nil, err
}
// Stat a volume entry.
_, err = osStat((volumeDir))
_, err = os.Stat((volumeDir))
if err != nil {
if os.IsNotExist(err) {
return nil, errVolumeNotFound
@@ -489,7 +489,7 @@ func (s *posix) ReadAll(volume, path string) (buf []byte, err error) {
return nil, err
}
// Stat a volume entry.
_, err = osStat((volumeDir))
_, err = os.Stat((volumeDir))
if err != nil {
if os.IsNotExist(err) {
return nil, errVolumeNotFound
@@ -560,7 +560,7 @@ func (s *posix) ReadFile(volume, path string, offset int64, buffer []byte, verif
return 0, err
}
// Stat a volume entry.
_, err = osStat((volumeDir))
_, err = os.Stat((volumeDir))
if err != nil {
if os.IsNotExist(err) {
return 0, errVolumeNotFound
@@ -652,7 +652,7 @@ func (s *posix) createFile(volume, path string) (f *os.File, err error) {
return nil, err
}
// Stat a volume entry.
_, err = osStat((volumeDir))
_, err = os.Stat((volumeDir))
if err != nil {
if os.IsNotExist(err) {
return nil, errVolumeNotFound
@@ -667,7 +667,7 @@ func (s *posix) createFile(volume, path string) (f *os.File, err error) {
// Verify if the file already exists and is not of regular type.
var st os.FileInfo
if st, err = osStat((filePath)); err == nil {
if st, err = os.Stat((filePath)); err == nil {
if !st.Mode().IsRegular() {
return nil, errIsNotRegular
}
@@ -794,7 +794,7 @@ func (s *posix) StatFile(volume, path string) (file FileInfo, err error) {
return FileInfo{}, err
}
// Stat a volume entry.
_, err = osStat((volumeDir))
_, err = os.Stat((volumeDir))
if err != nil {
if os.IsNotExist(err) {
return FileInfo{}, errVolumeNotFound
@@ -806,7 +806,7 @@ func (s *posix) StatFile(volume, path string) (file FileInfo, err error) {
if err = checkPathLength((filePath)); err != nil {
return FileInfo{}, err
}
st, err := osStat((filePath))
st, err := os.Stat((filePath))
if err != nil {
// File is really not found.
if os.IsNotExist(err) {
@@ -887,7 +887,7 @@ func (s *posix) DeleteFile(volume, path string) (err error) {
return err
}
// Stat a volume entry.
_, err = osStat((volumeDir))
_, err = os.Stat((volumeDir))
if err != nil {
if os.IsNotExist(err) {
return errVolumeNotFound
@@ -931,14 +931,14 @@ func (s *posix) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) (err e
return err
}
// Stat a volume entry.
_, err = osStat((srcVolumeDir))
_, err = os.Stat((srcVolumeDir))
if err != nil {
if os.IsNotExist(err) {
return errVolumeNotFound
}
return err
}
_, err = osStat((dstVolumeDir))
_, err = os.Stat((dstVolumeDir))
if err != nil {
if os.IsNotExist(err) {
return errVolumeNotFound
@@ -961,7 +961,7 @@ func (s *posix) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) (err e
}
if srcIsDir {
// If source is a directory we expect the destination to be non-existent always.
_, err = osStat((dstFilePath))
_, err = os.Stat((dstFilePath))
if err == nil {
return errFileAccessDenied
}

View File

@@ -110,8 +110,9 @@ func getModTime(path string) (t time.Time, err error) {
return t, fmt.Errorf("Unable to get absolute path of %s. %s", path, err)
}
// Get Stat info
fi, err := osStat(absPath)
// Version is minio non-standard, we will use minio binary's
// ModTime as release time.
fi, err := os.Stat(absPath)
if err != nil {
return t, fmt.Errorf("Unable to get ModTime of %s. %s", absPath, err)
}
@@ -141,7 +142,7 @@ func GetCurrentReleaseTime() (releaseTime time.Time, err error) {
// "/.dockerenv": "file",
//
func IsDocker() bool {
_, err := osStat("/.dockerenv")
_, err := os.Stat("/.dockerenv")
if os.IsNotExist(err) {
return false
}

View File

@@ -26,6 +26,7 @@ import (
"io"
"net/http"
"net/url"
"os"
"strings"
"time"
@@ -187,7 +188,7 @@ func dumpRequest(r *http.Request) string {
// isFile - returns whether given path is a file or not.
func isFile(path string) bool {
if fi, err := osStat(path); err == nil {
if fi, err := os.Stat(path); err == nil {
return fi.Mode().IsRegular()
}