Skip to content

Commit d9c8b10

Browse files
author
Dan
committed
Fix copy file directory creation logic
1 parent c565a63 commit d9c8b10

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pssh/ssh_client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ def copy_file(self, local_file, remote_file, recurse=False):
318318
raise ValueError("Recurse must be true if local_file is a "
319319
"directory.")
320320
sftp = self._make_sftp()
321-
destination = [_dir for _dir in remote_file.split(os.path.sep)
322-
if _dir][:-1][0]
323-
if remote_file.startswith(os.path.sep):
321+
try:
322+
destination = [_dir for _dir in remote_file.split(os.path.sep)
323+
if _dir][:-1][0]
324+
except IndexError:
325+
destination = ''
326+
if remote_file.startswith(os.path.sep) or not destination:
324327
destination = os.path.sep + destination
325328
try:
326329
sftp.stat(destination)

0 commit comments

Comments
 (0)