Skip to content

Can't download directories with spaces with get_r #73

@Rfromearth

Description

@Rfromearth

Hello, I'd like to use the get_r method, but it fails, when the remote directory contains folders named like this one:

1.10 oneword

The name of the downloaded folder is '1' and other folders (e.g. 1.10.10 two words) aren't even downloaded.
Everything works well with Filezilla so I believe that the server config is okay.

example.py

import sftpretty

hostname = 'xx.xx.xx'
port = 22
username = 'ftpuser'
password = 'password'
local_dir = '/home/user/local_dir'
remote_dir = '/home/ftpuser/testfiles'

cnopts = sftpretty.CnOpts(knownhosts=None)
cnopts.hostkeys = None
with sftpretty.Connection(host=hostname,
                          port=port,
                          username=username,
                          password=password,
                          cnopts=cnopts) as sftp:
    print(f'Downloading {remote_dir}')
    sftp.chdir(f'{remote_dir}')
    print(sftp.pwd)
    print(sftp.listdir())
    sftp.get_r(sftp.pwd, f'{local_dir}', preserve_mtime=True, resume=True )
    print(sftp.pwd)

Thank you in advance for looking into my issue.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions