"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
sftp: fix hash check for names starting with "-" with relative --sftp-path-override
Dirk Einecke4c52ae057564
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.goindex ec520fe2f..5cc4dd1a9 100644--- a/backend/sftp/sftp.go+++ b/backend/sftp/sftp.go@@ -2547,6 +2547,10 @@ func (f *Fs) remoteShellPath(remote string) string {if f.opt.PathOverride[0] == '@' {shellPath = path.Join(strings.TrimPrefix(f.opt.PathOverride, "@"), f.absRoot, encodedRemote)}+ // A relative path starting with "-" would be parsed as an option by the hash command+ if strings.HasPrefix(shellPath, "-") {+ shellPath = "./" + shellPath+ }fs.Debugf(f, "Shell path redirected to %q with option path_override", shellPath)return shellPath}diff --git a/backend/sftp/sftp_internal_test.go b/backend/sftp/sftp_internal_test.goindex 26306c29c..e4d11735a 100644--- a/backend/sftp/sftp_internal_test.go+++ b/backend/sftp/sftp_internal_test.go@@ -146,6 +146,23 @@ func TestRemoteShellPathEncodesPathOverrideNames(t *testing.T) {assert.Equal(t, "/volume/srv/root/dir/file\uFF1Aname", f.remoteShellPath("dir/file:name"))}+func TestRemoteShellPathRelativePathOverrideLeadingDash(t *testing.T) {+ f := &Fs{+ absRoot: "/",+ opt: Options{+ Enc: encoder.Display,+ PathOverride: "@.",+ },+ }++ assert.Equal(t, "./-file", f.remoteShellPath("-file"))+ assert.Equal(t, "dir/-file", f.remoteShellPath("dir/-file"))+ assert.Equal(t, "file", f.remoteShellPath("file"))++ f.opt.PathOverride = "."+ assert.Equal(t, "./-file", f.remoteShellPath("-file"))+}+func TestParseHash(t *testing.T) {for i, test := range []struct {sshOutput, checksum string