summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-03-28 01:18:26 +0100
committerCarl Hetherington <cth@carlh.net>2018-03-28 01:18:26 +0100
commit58a51d76d1935db64e10f6d6c24e94b60307123e (patch)
tree2d6fc9a29a315a0a278b6c10c14a4c29c282deb2
parent451858ca537c37fe27719df09c2aad0943899617 (diff)
scp to a temporary file first.
-rwxr-xr-xcdist10
1 files changed, 9 insertions, 1 deletions
diff --git a/cdist b/cdist
index 1c74336..fbec567 100755
--- a/cdist
+++ b/cdist
@@ -173,7 +173,15 @@ def copyfile(a, b):
if b.startswith('s3://'):
command('s3cmd -P put "%s" "%s"' % (a, b))
else:
- command('scp %s %s' % (scp_escape(a), scp_escape(b)))
+ bc = b.find(":")
+ if bc != -1:
+ host = b[:bc]
+ path = b[bc+1:]
+ temp_path = os.path.join(os.path.dirname(path), ".tmp." + os.path.basename(path))
+ command('scp %s %s:%s' % (scp_escape(a), host, scp_escape(temp_path)))
+ command('ssh %s -- mv %s %s' % (host, scp_escape(temp_path), scp_escape(path)))
+ else:
+ command('scp %s %s' % (scp_escape(a), scp_escape(b)))
def makedirs(d):
"""