Repository: rclone/rclone
File: fs/sync/sync.go (Go)

Code before:
					s.processError(err)
					s.logger(s.ctx, operations.TransferError, pair.Src, pair.Dst, err)
				}
				if NoNeedTransfer {
					needTransfer = 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, pair.Dst, 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 match
				if s.ci.Immutable && pair.Dst != nil {
					err := fs.CountError(fserrors.NoRetryError(fs.ErrorImmutableModified))
					fs.Errorf(pair.Dst, "Source and destination exist but do not match: %v", err)
					s.processError(err)
				} else {
					if pair.Dst != nil {
						s.markDirModified(path.Dir(filepath.ToSlash(pair.Dst.Remote())))
					} else {
						s.markDirModified(path.Dir(filepath.ToSlash(src.Remote())))
					}
					// If destination already exists, then we must move it into --backup-dir if required
					if pair.Dst != nil && s.backupDir != nil {
						err := operations.MoveBackupDir(s.ctx, s.backupDir, pair.Dst)
						if err != nil {
							s.processError(err)
							s.logger(s.ctx, operations.TransferError, pair.Src, pair.Dst, err)
						} else {
							// If successful zero out the dst as it is no longer there and copy the file
							pair.Dst = nil
							ok = out.Put(s.inCtx, pair)
							if !ok {
								return
							}
						}
					} else {
						ok = out.Put(s.inCtx, pair)
						if !ok {
							return
						}
					}
				}
			} else {

Review comment (bug):
This should not need `filepath.ToSlash` here - all paths should be unix `/` delimited in rclone internals.

If they aren't then that is a bug somewhere else :-)

Please remove them all from this file! Also see later suggestion for a function `markDirModifiedObject`...

Code after:
					s.logger(s.ctx, operations.TransferError, pair.Src, pair.Dst, err)
				}
				if NoNeedTransfer {
					needTransfer = 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, pair.Dst, 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 match
				if s.ci.Immutable && pair.Dst != nil {
					err := fs.CountError(fserrors.NoRetryError(fs.ErrorImmutableModified))
					fs.Errorf(pair.Dst, "Source and destination exist but do not match: %v", err)
					s.processError(err)
				} else {
					if pair.Dst != nil {
						s.markDirModifiedObject(pair.Dst)
					} else {
						s.markDirModifiedObject(src)
					}
					// If destination already exists, then we must move it into --backup-dir if required
					if pair.Dst != nil && s.backupDir != nil {
						err := operations.MoveBackupDir(s.ctx, s.backupDir, pair.Dst)
						if err != nil {
							s.processError(err)
							s.logger(s.ctx, operations.TransferError, pair.Src, pair.Dst, err)
						} else {
							// If successful zero out the dst as it is no longer there and copy the file
							pair.Dst = nil
							ok = out.Put(s.inCtx, pair)
							if !ok {
								return
							}
						}
					} else {
						ok = out.Put(s.inCtx, pair)
						if !ok {
							return
						}
					}
				}
			} else {
				// If moving need to delete the files we don't need to copy