Navigation Menu

Skip to content

Commit

Permalink
fixes fabric#1341: clean up temp file with sudo uploads if destinatio…
Browse files Browse the repository at this point in the history
…n path is invalid
  • Loading branch information
UkuLoskit committed Apr 7, 2017
1 parent 1f585a5 commit 66c3a62
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fabric/sftp.py
Expand Up @@ -287,7 +287,11 @@ def put(self, local_path, remote_path, use_sudo, mirror_local_mode, mode,
# Temporarily nuke 'cwd' so sudo() doesn't "cd" its mv command.
# (The target path has already been cwd-ified elsewhere.)
with settings(hide('everything'), cwd=""):
sudo("mv \"%s\" \"%s\"" % (remote_path, target_path))
try:
sudo("mv \"%s\" \"%s\"" % (remote_path, target_path))
except BaseException:
sudo("rm -f \"%s\"" % remote_path)
raise
# Revert to original remote_path for return value's sake
remote_path = target_path
return remote_path
Expand Down

0 comments on commit 66c3a62

Please sign in to comment.