diff --git a/cmd/fs-v1-helpers_contrib.go b/cmd/fs-v1-helpers_contrib.go deleted file mode 100644 index 5d2dd13f5..000000000 --- a/cmd/fs-v1-helpers_contrib.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * MinIO Object Storage (c) 2021 MinIO, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cmd - -import ( - "context" - "os" - - "github.com/minio/minio/internal/logger" -) - -// 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 - } - if err := checkPathLength(destPath); err != nil { - logger.LogIf(ctx, err) - return err - } - - if err := os.Rename(sourcePath, destPath); err != nil { - logger.LogIf(ctx, err) - return osErrToFileErr(err) - } - - return nil -} diff --git a/cmd/fs-v1-multipart.go b/cmd/fs-v1-multipart.go index e0afa6464..3cc490e51 100644 --- a/cmd/fs-v1-multipart.go +++ b/cmd/fs-v1-multipart.go @@ -340,7 +340,7 @@ func (fs *FSObjects) PutObjectPart(ctx context.Context, bucket, object, uploadID partPath := pathJoin(uploadIDDir, fs.encodePartFile(partID, etag, data.ActualSize())) // Make sure not to create parent directories if they don't exist - the upload might have been aborted. - if err = fsSimpleRenameFile(ctx, tmpPartPath, partPath); err != nil { + if err = Rename(tmpPartPath, partPath); err != nil { if err == errFileNotFound || err == errFileAccessDenied { return pi, InvalidUploadID{Bucket: bucket, Object: object, UploadID: uploadID} } @@ -776,7 +776,7 @@ func (fs *FSObjects) CompleteMultipartUpload(ctx context.Context, bucket string, fsTmpObjPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, mustGetUUID()) defer fsRemoveAll(ctx, fsTmpObjPath) // remove multipart temporary files in background. - fsSimpleRenameFile(ctx, uploadIDDir, fsTmpObjPath) + Rename(uploadIDDir, fsTmpObjPath) // It is safe to ignore any directory not empty error (in case there were multiple uploadIDs on the same object) fsRemoveDir(ctx, fs.getMultipartSHADir(bucket, object)) @@ -835,7 +835,7 @@ func (fs *FSObjects) AbortMultipartUpload(ctx context.Context, bucket, object, u fsTmpObjPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, mustGetUUID()) defer fsRemoveAll(ctx, fsTmpObjPath) // remove multipart temporary files in background. - fsSimpleRenameFile(ctx, uploadIDDir, fsTmpObjPath) + Rename(uploadIDDir, fsTmpObjPath) // It is safe to ignore any directory not empty error (in case there were multiple uploadIDs on the same object) fsRemoveDir(ctx, fs.getMultipartSHADir(bucket, object)) diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index e83ef2848..bf20f73a2 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -580,7 +580,7 @@ func (fs *FSObjects) DeleteBucket(ctx context.Context, bucket string, opts Delet } } else { tmpBucketPath := pathJoin(fs.fsPath, minioMetaTmpBucket, bucket+"."+mustGetUUID()) - if err = fsSimpleRenameFile(ctx, bucketDir, tmpBucketPath); err != nil { + if err = Rename(bucketDir, tmpBucketPath); err != nil { return toObjectErr(err, bucket) } diff --git a/cmd/xl-storage-format-utils_test.go b/cmd/xl-storage-format-utils_test.go index 4b087bddf..ee7d48fbf 100644 --- a/cmd/xl-storage-format-utils_test.go +++ b/cmd/xl-storage-format-utils_test.go @@ -1,3 +1,20 @@ +// Copyright (c) 2015-2021 MinIO, Inc. +// +// This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package cmd import (