fix:send func
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const defaultPort = "22"
|
const defaultPort = "22"
|
||||||
const defaultStoragePath = "~/.filepass_storage"
|
const defaultStoragePath = ".filepass_storage"
|
||||||
|
|
||||||
// shellQuote wraps s in single quotes, escaping any single quotes within it.
|
// shellQuote wraps s in single quotes, escaping any single quotes within it.
|
||||||
// This is safe for use in remote shell commands passed over SSH.
|
// This is safe for use in remote shell commands passed over SSH.
|
||||||
@@ -35,7 +35,8 @@ func SSHCmd(s Server, remoteCmd string) *exec.Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RsyncCmd returns an exec.Cmd for an rsync transfer.
|
// RsyncCmd returns an exec.Cmd for an rsync transfer.
|
||||||
// src and dst follow standard rsync syntax (local path or user@host:path).
|
// --protect-args (-s) prevents rsync from shell-expanding the remote path,
|
||||||
|
// which correctly handles filenames with spaces and special characters.
|
||||||
func RsyncCmd(s Server, src, dst string) *exec.Cmd {
|
func RsyncCmd(s Server, src, dst string) *exec.Cmd {
|
||||||
sshFlag := "ssh -i " + s.PrivateKey + " -p " + serverPort(s) +
|
sshFlag := "ssh -i " + s.PrivateKey + " -p " + serverPort(s) +
|
||||||
" -o StrictHostKeyChecking=no -o BatchMode=yes"
|
" -o StrictHostKeyChecking=no -o BatchMode=yes"
|
||||||
@@ -43,6 +44,7 @@ func RsyncCmd(s Server, src, dst string) *exec.Cmd {
|
|||||||
"rsync",
|
"rsync",
|
||||||
"-avz",
|
"-avz",
|
||||||
"--partial",
|
"--partial",
|
||||||
|
"--protect-args",
|
||||||
"-e", sshFlag,
|
"-e", sshFlag,
|
||||||
src,
|
src,
|
||||||
dst,
|
dst,
|
||||||
@@ -50,9 +52,9 @@ func RsyncCmd(s Server, src, dst string) *exec.Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemotePath returns the full remote rsync path for a filename inside storage.
|
// RemotePath returns the full remote rsync path for a filename inside storage.
|
||||||
// Only the filename is shell-quoted so ~ expands correctly on the remote shell.
|
// No shell quoting needed — --protect-args in RsyncCmd handles special characters.
|
||||||
func RemotePath(s Server, filename string) string {
|
func RemotePath(s Server, filename string) string {
|
||||||
return s.User + "@" + s.Host + ":" + defaultStoragePath + "/" + shellQuote(filename)
|
return s.User + "@" + s.Host + ":" + defaultStoragePath + "/" + filename
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoteStorageRoot returns the remote storage root for rsync operations.
|
// RemoteStorageRoot returns the remote storage root for rsync operations.
|
||||||
|
|||||||
Reference in New Issue
Block a user