diff options
Diffstat (limited to 'gear/worker.py')
-rw-r--r-- | gear/worker.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gear/worker.py b/gear/worker.py index f7cb9d28..e8abacda 100644 --- a/gear/worker.py +++ b/gear/worker.py @@ -43,16 +43,17 @@ def upload_files(cache_key, suffixes): sftp = client.open_sftp() for single_file in files_to_upload: remote_dest = os.path.join(remote_cache_dir, os.path.basename(single_file)) + remote_dest_tmp = os.path.join(remote_cache_dir, os.path.basename(single_file) + '.tmp') print "DEBUG: going to upload %s" % single_file print "DEBUG: upload destination %s" % remote_dest - # TODO: atomic upload!! sftp.rename(remotePath+'/tmp/'+fileName, remotePath+fileName) try: sftp.stat(remote_dest) print "DEBUG: file already exists" return except: print "DEBUG: file not found in cache, uploading" - sftp.put(single_file, remote_dest) + sftp.put(single_file, remote_dest_tmp) + sftp.rename(remote_dest_tmp, remote_dest) while True: print "DEBUG: Waiting for job" |