sftp: Add --ssh-path-override flag #1474

The flag allows calculation of checksums on systems using
different paths for SSH and SFTP, like synology NAS boxes.
This commit is contained in:
Piotr Oleszczyk
2018-04-30 18:05:10 +02:00
committed by Nick Craig-Wood
parent 0479c7dcf5
commit 76f2cbeb94
2 changed files with 18 additions and 0 deletions

View File

@@ -41,6 +41,7 @@ var (
// Flags
sftpAskPassword = flags.BoolP("sftp-ask-password", "", false, "Allow asking for SFTP password when needed.")
sshPathOverride = flags.StringP("ssh-path-override", "", "", "Override path used by SSH connection.")
)
func init() {
@@ -763,6 +764,9 @@ func (o *Object) Hash(r hash.Type) (string, error) {
session.Stdout = &stdout
session.Stderr = &stderr
escapedPath := shellEscape(o.path())
if *sshPathOverride != "" {
escapedPath = shellEscape(path.Join(*sshPathOverride, o.remote))
}
err = session.Run(hashCmd + " " + escapedPath)
if err != nil {
_ = session.Close()