Skip to content

Commit

Permalink
safer handling of result archives
Browse files Browse the repository at this point in the history
  • Loading branch information
janbuchar committed Dec 13, 2017
1 parent 40f9c75 commit 0c82728
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fileserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ def store_result(id, ext, dirs: DirectoryStructure):
"""

path = os.path.join(dirs.result_dir, "{0}.{1}".format(id, ext))
with open(path, 'wb') as f:
path_tmp = path + ".part"
with open(path_tmp, 'wb') as f:
f.write(request.data)

os.replace(path_tmp, path)

return json.dumps({
"result": "OK"
})
Expand Down

0 comments on commit 0c82728

Please sign in to comment.