"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
sync: use operations.DirMove instead of sync.MoveDir for --fix-case - #7591
nielash137f7f62fbc4
diff --git a/fs/operations/operations.go b/fs/operations/operations.goindex c68f468ff..95d987d05 100644--- a/fs/operations/operations.go+++ b/fs/operations/operations.go@@ -2288,6 +2288,17 @@ func DirMove(ctx context.Context, f fs.Fs, srcRemote, dstRemote string) (err errreturn nil}+// DirMoveCaseInsensitive does DirMove in two steps (to temp name, then real name)+// which is necessary for some case-insensitive backends+func DirMoveCaseInsensitive(ctx context.Context, f fs.Fs, srcRemote, dstRemote string) (err error) {+ tmpDstRemote := dstRemote + "-rclone-move-" + random.String(8)+ err = DirMove(ctx, f, srcRemote, tmpDstRemote)+ if err != nil {+ return err+ }+ return DirMove(ctx, f, tmpDstRemote, dstRemote)+}+// FsInfo provides information about a remotetype FsInfo struct {// Name of the remote (as passed into NewFs)diff --git a/fs/sync/sync.go b/fs/sync/sync.goindex ddbe03a07..c464235c0 100644--- a/fs/sync/sync.go+++ b/fs/sync/sync.go@@ -6,7 +6,6 @@ import ("errors""fmt""path"- "path/filepath""sort""strings""sync"@@ -19,7 +18,6 @@ import ("github.com/rclone/rclone/fs/hash""github.com/rclone/rclone/fs/march""github.com/rclone/rclone/fs/operations"- "github.com/rclone/rclone/lib/random")// ErrorMaxDurationReached defines error when transfer duration is reached@@ -1151,25 +1149,12 @@ func (s *syncCopyMove) Match(ctx context.Context, dst, src fs.DirEntry) (recurseif s.ci.FixCase && !s.ci.Immutable && src.Remote() != dst.Remote() {// Fix case for case insensitive filesystems// Fix each dir before recursing into subdirs and files- oldDirFs, err := fs.NewFs(s.ctx, filepath.Join(fs.ConfigStringFull(s.fdst), dst.Remote()))- s.processError(err)- newDirPath := filepath.Join(fs.ConfigStringFull(s.fdst), filepath.Dir(dst.Remote()), filepath.Base(src.Remote()))- newDirFs, err := fs.NewFs(s.ctx, newDirPath)- s.processError(err)- // Create random name to temporarily move dir to- tmpDirName := newDirPath + "-rclone-move-" + random.String(8)- tmpDirFs, err := fs.NewFs(s.ctx, tmpDirName)- s.processError(err)- if err = MoveDir(s.ctx, tmpDirFs, oldDirFs, s.deleteEmptySrcDirs, s.copyEmptySrcDirs); err != nil {- fs.Errorf(dst, "Error while attempting to move dir to temporary location %s: %v", tmpDirName, err)+ err := operations.DirMoveCaseInsensitive(s.ctx, s.fdst, dst.Remote(), src.Remote())+ if err != nil {+ fs.Errorf(dst, "Error while attempting to rename to %s: %v", src.Remote(), err)s.processError(err)} else {- if err = MoveDir(s.ctx, newDirFs, tmpDirFs, s.deleteEmptySrcDirs, s.copyEmptySrcDirs); err != nil {- fs.Errorf(dst, "Error while attempting to rename to %s: %v", src.Remote(), err)- s.processError(err)- } else {- fs.Infof(dst, "Fixed case by renaming to: %s", src.Remote())- }+ fs.Infof(dst, "Fixed case by renaming to: %s", src.Remote())}}