From 39d681a04a7fce1d61e8ea60590c0e7419962cab Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 8 May 2021 22:31:41 -0700 Subject: [PATCH] update fsSimpleRenameFile contrib --- cmd/fs-v1-helpers.go | 10 +++++----- cmd/fs-v1-helpers_contrib.go | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/fs-v1-helpers.go b/cmd/fs-v1-helpers.go index 66a5c2fca..291d1b4d2 100644 --- a/cmd/fs-v1-helpers.go +++ b/cmd/fs-v1-helpers.go @@ -320,9 +320,9 @@ func fsCreateFile(ctx context.Context, filePath string, reader io.Reader, falloc return bytesWritten, nil } -// Renames source path to destination path, fails if the destination path -// parents are not already created. -func fsSimpleRenameFile(ctx context.Context, sourcePath, destPath string) error { +// Renames source path to destination path, creates all the +// missing parents if they don't exist. +func fsRenameFile(ctx context.Context, sourcePath, destPath string) error { if err := checkPathLength(sourcePath); err != nil { logger.LogIf(ctx, err) return err @@ -332,9 +332,9 @@ func fsSimpleRenameFile(ctx context.Context, sourcePath, destPath string) error return err } - if err := os.Rename(sourcePath, destPath); err != nil { + if err := renameAll(sourcePath, destPath); err != nil { logger.LogIf(ctx, err) - return osErrToFileErr(err) + return err } return nil diff --git a/cmd/fs-v1-helpers_contrib.go b/cmd/fs-v1-helpers_contrib.go index dede23d2e..588009421 100644 --- a/cmd/fs-v1-helpers_contrib.go +++ b/cmd/fs-v1-helpers_contrib.go @@ -18,13 +18,14 @@ package cmd import ( "context" + "os" "github.com/minio/minio/cmd/logger" ) -// Renames source path to destination path, creates all the -// missing parents if they don't exist. -func fsRenameFile(ctx context.Context, sourcePath, destPath string) error { +// Renames source path to destination path, fails if the destination path +// parents are not already created. +func fsSimpleRenameFile(ctx context.Context, sourcePath, destPath string) error { if err := checkPathLength(sourcePath); err != nil { logger.LogIf(ctx, err) return err @@ -34,9 +35,9 @@ func fsRenameFile(ctx context.Context, sourcePath, destPath string) error { return err } - if err := renameAll(sourcePath, destPath); err != nil { + if err := os.Rename(sourcePath, destPath); err != nil { logger.LogIf(ctx, err) - return err + return osErrToFileErr(err) } return nil