Always copy source directory contents, not the directory itself

This commit is contained in:
2026-07-17 18:40:16 -04:00
parent 340370a43b
commit b2172145e7
3 changed files with 101 additions and 8 deletions
+15 -2
View File
@@ -69,15 +69,28 @@ func (r *RsyncRunner) buildArgs(pair *SyncPairConfig) []string {
args = append(args, "--delete")
}
src := ensureDirSlash(pair.Source)
if pair.Direction == "pull" {
args = append(args, pair.Dest, pair.Source)
args = append(args, pair.Dest, src)
} else {
args = append(args, pair.Source, pair.Dest)
args = append(args, src, pair.Dest)
}
return args
}
// ensureDirSlash guarantees the source path is treated by rsync as a
// directory whose contents are copied, regardless of whether the user
// supplied a trailing slash. This avoids the common foot-gun where
// "rsync host:/path/series /dest/" creates /dest/series/<contents> nested
// inside an extra "series" subdirectory.
func ensureDirSlash(p string) string {
if strings.HasSuffix(p, "/") {
return p
}
return p + "/"
}
type MachineKeys struct {
Host string
Port int