Skip to content

Commit

Permalink
Fix copy file directory creation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pkittenis committed Dec 10, 2015
1 parent c565a63 commit d9c8b10
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pssh/ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,12 @@ def copy_file(self, local_file, remote_file, recurse=False):
raise ValueError("Recurse must be true if local_file is a "
"directory.")
sftp = self._make_sftp()
destination = [_dir for _dir in remote_file.split(os.path.sep)
if _dir][:-1][0]
if remote_file.startswith(os.path.sep):
try:
destination = [_dir for _dir in remote_file.split(os.path.sep)
if _dir][:-1][0]
except IndexError:
destination = ''
if remote_file.startswith(os.path.sep) or not destination:
destination = os.path.sep + destination
try:
sftp.stat(destination)
Expand Down

0 comments on commit d9c8b10

Please sign in to comment.