"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: fix --fix-case rename failing on backends that can't update modtime
Nick Craig-Woodde67f29b3fe3
diff --git a/fs/sync/sync.go b/fs/sync/sync.goindex 6ec0c074f..b3eca0a86 100644--- a/fs/sync/sync.go+++ b/fs/sync/sync.go@@ -380,6 +380,20 @@ func (s *syncCopyMove) pairChecker(in *pipe, out *pipe, fraction int, wg *sync.Wtr := accounting.Stats(s.ctx).NewCheckingTransfer(src, "checking")// Check to see if can store thisif src.Storable() {+ // Fix case for case insensitive filesystems before checking+ // whether a transfer is needed, since NeedTransfer may delete+ // the destination (when content matches but modtime can't be+ // set without re-upload), which would cause the rename below+ // to fail with a "not found" error.+ if s.ci.FixCase && !s.ci.Immutable && src.Remote() != pair.Dst.Remote() {+ if newDst, err := operations.Move(s.ctx, s.fdst, nil, src.Remote(), pair.Dst); err != nil {+ fs.Errorf(pair.Dst, "Error while attempting to rename to %s: %v", src.Remote(), err)+ s.processError(err)+ } else {+ fs.Infof(pair.Dst, "Fixed case by renaming to: %s", src.Remote())+ pair.Dst = newDst+ }+ }needTransfer := operations.NeedTransfer(s.ctx, pair.Dst, pair.Src)if needTransfer {NoNeedTransfer, err := operations.CompareOrCopyDest(s.ctx, s.fdst, pair.Dst, pair.Src, s.compareCopyDest, s.backupDir)@@ -391,16 +405,6 @@ func (s *syncCopyMove) pairChecker(in *pipe, out *pipe, fraction int, wg *sync.WneedTransfer = false}}- // Fix case for case insensitive filesystems- if s.ci.FixCase && !s.ci.Immutable && src.Remote() != pair.Dst.Remote() {- if newDst, err := operations.Move(s.ctx, s.fdst, nil, src.Remote(), pair.Dst); err != nil {- fs.Errorf(pair.Dst, "Error while attempting to rename to %s: %v", src.Remote(), err)- s.processError(err)- } else {- fs.Infof(pair.Dst, "Fixed case by renaming to: %s", src.Remote())- pair.Dst = newDst- }- }if needTransfer {// If files are treated as immutable, fail if destination exists and does not matchif s.ci.Immutable && pair.Dst != nil {