fix: simplify RunRemote to not re-prefix source or dest

RunRemote was adding user@host: prefixes on top of the paths already
pre-prefixed by engine.go in the remote-to-remote branch, causing
"both remote" rsync errors. The source path was also incorrectly
prefixed with srcUserHost:, making rsync reject the command entirely.

The fix: buildArgs already orders args correctly for rsync (source
then dest), so just use args[-2] and args[-1] as-is without any
additional prefixing.
This commit is contained in:
2026-07-09 21:58:02 -04:00
parent fce8962f2b
commit 5b28b46e6b
3 changed files with 19 additions and 64 deletions
+3 -26
View File
@@ -96,39 +96,16 @@ func (r *RsyncRunner) RunRemote(ctx context.Context, pair *SyncPairConfig, src *
destKey = filepath.Join(r.sshDir, "id_ed25519")
}
srcUserHost := fmt.Sprintf("%s@%s", src.SSHUser, src.Host)
args := r.buildArgs(pair)
innerSSH := fmt.Sprintf("ssh -i %s -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=%s",
destKey, filepath.Join(r.sshDir, "known_hosts"))
rsyncFlags := strings.Join(args[:len(args)-2], " ")
var sourcePath, destPath string
if pair.Direction == "pull" {
sourcePath = args[len(args)-1]
destPath = args[len(args)-2]
} else {
sourcePath = args[len(args)-2]
destPath = args[len(args)-1]
}
var remoteSrc, remoteDst string
if pair.Direction == "pull" {
remoteSrc = sourcePath
remoteDst = destPath
if !strings.Contains(destPath, "@") {
remoteDst = fmt.Sprintf("%s@%s:%s", dst.SSHUser, dst.Host, destPath)
}
} else {
remoteDst = destPath
if !strings.Contains(destPath, "@") {
remoteDst = fmt.Sprintf("%s@%s:%s", dst.SSHUser, dst.Host, destPath)
}
remoteSrc = fmt.Sprintf("%s:%s", srcUserHost, sourcePath)
}
sourcePath := args[len(args)-2]
destPath := args[len(args)-1]
remoteCmd := fmt.Sprintf("rsync %s -e %q %s %s",
rsyncFlags, innerSSH, remoteSrc, remoteDst)
rsyncFlags, innerSSH, sourcePath, destPath)
sshArgs := []string{
"-i", src.PrivKey,