Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

operations: fix renaming a file on macOS

nielash7c6f0cc455f5
diff --git a/fs/operations/operations.go b/fs/operations/operations.go
index b71e6adc5..8772f0d6a 100644
--- a/fs/operations/operations.go
+++ b/fs/operations/operations.go
@@ -16,6 +16,7 @@ import (
"os"
"path"
"path/filepath"
+ "runtime"
"sort"
"strconv"
"strings"
@@ -37,6 +38,7 @@ import (
"github.com/rclone/rclone/lib/random"
"github.com/rclone/rclone/lib/readers"
"golang.org/x/sync/errgroup"
+ "golang.org/x/text/unicode/norm"
)
// CheckHashes checks the two files to see if they have common
@@ -328,6 +330,11 @@ func SameObject(src, dst fs.Object) bool {
}
srcPath := path.Join(srcFs.Root(), src.Remote())
dstPath := path.Join(dstFs.Root(), dst.Remote())
+ if srcFs.Features().IsLocal && dstFs.Features().IsLocal && runtime.GOOS == "darwin" {
+ if norm.NFC.String(srcPath) == norm.NFC.String(dstPath) {
+ return true
+ }
+ }
if dst.Fs().Features().CaseInsensitive {
srcPath = strings.ToLower(srcPath)
dstPath = strings.ToLower(dstPath)
@@ -1565,7 +1572,7 @@ func NeedTransfer(ctx context.Context, dst, src fs.Object) bool {
}
} else {
// Check to see if changed or not
- if Equal(ctx, src, dst) {
+ if Equal(ctx, src, dst) && !SameObject(src, dst) {
fs.Debugf(src, "Unchanged skipping")
return false
}
@@ -1847,7 +1854,7 @@ func moveOrCopyFile(ctx context.Context, fdst fs.Fs, fsrc fs.Fs, dstFileName str
if ci.IgnoreExisting {
fs.Debugf(srcObj, "Not removing source file as destination file exists and --ignore-existing is set")
logger(ctx, Match, srcObj, dstObj, nil)
- } else {
+ } else if !SameObject(srcObj, dstObj) {
err = DeleteFile(ctx, srcObj)
logger(ctx, Differ, srcObj, dstObj, nil)
}