mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
use syscall.Rename() directly instead of os.Rename() (#17982)
This commit is contained in:
parent
5b114b43f7
commit
1e51424e8a
@ -137,7 +137,7 @@ func MkdirAll(dirPath string, mode os.FileMode) (err error) {
|
||||
// Rename captures time taken to call os.Rename
|
||||
func Rename(src, dst string) (err error) {
|
||||
defer updateOSMetrics(osMetricRename, src, dst)(err)
|
||||
return os.Rename(src, dst)
|
||||
return RenameSys(src, dst)
|
||||
}
|
||||
|
||||
// OpenFile captures time taken to call os.OpenFile
|
||||
|
@ -21,6 +21,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@ -29,3 +31,8 @@ func Rename2(src, dst string) (err error) {
|
||||
defer updateOSMetrics(osMetricRename2, src, dst)(err)
|
||||
return unix.Renameat2(unix.AT_FDCWD, src, unix.AT_FDCWD, dst, uint(2)) // RENAME_EXCHANGE from 'man renameat2'
|
||||
}
|
||||
|
||||
// RenameSys is low level call in case of Linux this uses syscall.Rename() directly.
|
||||
func RenameSys(src, dst string) (err error) {
|
||||
return syscall.Rename(src, dst)
|
||||
}
|
||||
|
@ -20,10 +20,18 @@
|
||||
|
||||
package cmd
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Rename2 is not implemented in a non linux environment
|
||||
func Rename2(src, dst string) (err error) {
|
||||
defer updateOSMetrics(osMetricRename2, src, dst)(errors.New("not implemented, skipping"))
|
||||
return errSkipFile
|
||||
}
|
||||
|
||||
// RenameSys is low level call in case of non-Linux this just uses os.Rename()
|
||||
func RenameSys(src, dst string) (err error) {
|
||||
return os.Rename(src, dst)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user