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

Code before:
	}
	maxTries := ci.LowLevelRetries
	tries := 0
	doUpdate := dst != nil
	hashType, hashOption := CommonHash(ctx, f, src.Fs())

	if dst != nil {
		remote = dst.Remote()
	}

	var (
		inplace       = true
		remotePartial = remote
	)
	if !ci.Inplace && f.Features().Move != nil && f.Features().PartialUploads && !strings.HasSuffix(remote, ".rclonelink") {
		// Avoid making the leaf name longer if it's already lengthy to avoid
		// trouble with file name length limits.
		ext := strings.TrimSpace(ci.PartialUploadExtension)
		if len(ext) == 0 {
			ext = fs.GetConfig(context.Background()).PartialUploadExtension
		}

		suffix := "." + random.String(8) + "." + ext
		base := path.Base(remotePartial)
		if len(base) > 100 {
			limit := len(base) - len(suffix)

			if len(suffix) > len(base) {
				limit = 1
			}

			remotePartial = remotePartial[:len(remotePartial)-len(base)+limit] + suffix
		} else {
			remotePartial += suffix
		}
		inplace = false
	}

	var actionTaken string
	for {
		// Try server-side copy first - if has optional interface and
		// is same underlying remote
		actionTaken = "Copied (server-side copy)"
		if ci.MaxTransfer >= 0 {
			var bytesSoFar int64
			if ci.CutoffMode == fs.CutoffModeCautious {
				bytesSoFar = accounting.Stats(ctx).GetBytesWithPending() + src.Size()
			} else {
				bytesSoFar = accounting.Stats(ctx).GetBytes()
			}
			if bytesSoFar >= int64(ci.MaxTransfer) {

Review comment (suggestion):
I think since we've limited the size of the extension, we can just use the original 

    remotePartial = remotePartial[:len(remotePartial)-len(suffix)] + suffix

Here, which will give a max total length of 125 which is fine.

Code after:
	}
	maxTries := ci.LowLevelRetries
	tries := 0
	doUpdate := dst != nil
	hashType, hashOption := CommonHash(ctx, f, src.Fs())

	if dst != nil {
		remote = dst.Remote()
	}

	var (
		inplace       = true
		remotePartial = remote
	)
	if !ci.Inplace && f.Features().Move != nil && f.Features().PartialUploads && !strings.HasSuffix(remote, ".rclonelink") {
		if len(ci.PartialSuffix) > 16 {
			return nil, fmt.Errorf("expecting length of --partial-suffix to be not greater than %d but got %d", 16, len(ci.PartialSuffix))
		}

		// Avoid making the leaf name longer if it's already lengthy to avoid
		// trouble with file name length limits.
		suffix := "." + random.String(8) + ci.PartialSuffix
		base := path.Base(remotePartial)
		if len(base) > 100 {
			remotePartial = remotePartial[:len(remotePartial)-len(suffix)] + suffix
		} else {
			remotePartial += suffix
		}
		inplace = false
	}

	var actionTaken string
	for {
		// Try server-side copy first - if has optional interface and
		// is same underlying remote
		actionTaken = "Copied (server-side copy)"
		if ci.MaxTransfer >= 0 {
			var bytesSoFar int64
			if ci.CutoffMode == fs.CutoffModeCautious {
				bytesSoFar = accounting.Stats(ctx).GetBytesWithPending() + src.Size()
			} else {
				bytesSoFar = accounting.Stats(ctx).GetBytes()
			}
			if bytesSoFar >= int64(ci.MaxTransfer) {
				if ci.CutoffMode == fs.CutoffModeHard {
					return nil, accounting.ErrorMaxTransferLimitReachedFatal
				}
				return nil, accounting.ErrorMaxTransferLimitReachedGraceful
			}
		}
		if doCopy := f.Features().Copy; doCopy != nil && (SameConfig(src.Fs(), f) || (SameRemoteType(src.Fs(), f) && (f.Features().ServerSideAcrossConfigs || ci.ServerSideAcrossConfigs))) {