From ac82798d0aa32079656e6ac0a84c55fe29db7dba Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 24 Jul 2019 03:29:13 -0700 Subject: [PATCH] Remove uneeded calls on FS (#7967) --- cmd/fs-v1-helpers.go | 14 -------------- cmd/fs-v1-helpers_test.go | 12 ------------ cmd/fs-v1.go | 4 ---- 3 files changed, 30 deletions(-) diff --git a/cmd/fs-v1-helpers.go b/cmd/fs-v1-helpers.go index e06fcf554..f8a187a87 100644 --- a/cmd/fs-v1-helpers.go +++ b/cmd/fs-v1-helpers.go @@ -228,15 +228,6 @@ func fsStatDir(ctx context.Context, statDir string) (os.FileInfo, error) { return fi, nil } -// Returns if the dirPath is a directory. -func fsIsDir(ctx context.Context, dirPath string) bool { - fi, err := fsStat(ctx, dirPath) - if err != nil { - return false - } - return fi.IsDir() -} - // Lookup if file exists, returns file attributes upon success. func fsStatFile(ctx context.Context, statFile string) (os.FileInfo, error) { fi, err := fsStat(ctx, statFile) @@ -418,11 +409,6 @@ func fsRenameFile(ctx context.Context, sourcePath, destPath string) error { return err } - // Verify if source path exists. - if _, err := os.Stat(sourcePath); err != nil { - return osErrToFSFileErr(err) - } - if err := renameAll(sourcePath, destPath); err != nil { logger.LogIf(ctx, err) return err diff --git a/cmd/fs-v1-helpers_test.go b/cmd/fs-v1-helpers_test.go index fda7a1b7b..87fb8d293 100644 --- a/cmd/fs-v1-helpers_test.go +++ b/cmd/fs-v1-helpers_test.go @@ -548,18 +548,6 @@ func TestFSRemoveMeta(t *testing.T) { } } -func TestFSIsDir(t *testing.T) { - dirPath, err := ioutil.TempDir(globalTestTmpDir, "minio-") - if err != nil { - t.Fatalf("Unable to create tmp directory %s", err) - } - defer os.RemoveAll(dirPath) - - if !fsIsDir(context.Background(), dirPath) { - t.Fatalf("Expected %s to be a directory", dirPath) - } -} - func TestFSIsFile(t *testing.T) { dirPath, err := ioutil.TempDir(globalTestTmpDir, "minio-") if err != nil { diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 491efcb99..a26ae2db7 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -691,10 +691,6 @@ func (fs *FSObjects) defaultFsJSON(object string) fsMetaV1 { func (fs *FSObjects) getObjectInfo(ctx context.Context, bucket, object string) (oi ObjectInfo, e error) { fsMeta := fsMetaV1{} if hasSuffix(object, slashSeparator) { - // Since we support PUT of a "directory" object, we allow HEAD. - if !fsIsDir(ctx, pathJoin(fs.fsPath, bucket, object)) { - return oi, errFileNotFound - } fi, err := fsStatDir(ctx, pathJoin(fs.fsPath, bucket, object)) if err != nil { return oi, err