add internal/app/ship.go

This commit is contained in:
2026-09-30 21:59:31 +02:00
parent e841d16d2d
commit 0906fdbc9c
+33
View File
@@ -0,0 +1,33 @@
package app
import (
"fmt"
"os/exec"
)
// scpArgs builds the scp command line. Files are uploaded in the given order;
// callers pass the playlist LAST so stream links never 404 before the files.
func scpArgs(files []string, target, keyPath string) []string {
args := []string{"-o", "StrictHostKeyChecking=accept-new", "-q"}
if keyPath != "" {
args = append(args, "-i", keyPath)
}
args = append(args, files...)
args = append(args, target)
return args
}
// Ship uploads files to target (user@host:/path/) via scp.
func Ship(files []string, target, keyPath string) error {
if len(files) == 0 {
return nil
}
if target == "" {
return fmt.Errorf("ship target not configured")
}
out, err := exec.Command("scp", scpArgs(files, target, keyPath)...).CombinedOutput()
if err != nil {
return fmt.Errorf("scp to %s: %w: %s", target, err, out)
}
return nil
}