Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

sftp: fix NewObject with leading /

Nick Craig-Wood7edb4c0162a6
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index 109745267..c998180c7 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -1775,11 +1775,14 @@ func (o *Object) setMetadata(info os.FileInfo) {
// statRemote stats the file or directory at the remote given
func (f *Fs) stat(ctx context.Context, remote string) (info os.FileInfo, err error) {
+ absPath := remote
+ if !strings.HasPrefix(remote, "/") {
+ absPath = path.Join(f.absRoot, remote)
+ }
c, err := f.getSftpConnection(ctx)
if err != nil {
return nil, fmt.Errorf("stat: %w", err)
}
- absPath := path.Join(f.absRoot, remote)
info, err = c.sftpClient.Stat(absPath)
f.putSftpConnection(&c, err)
return info, err