store tmp file and move to location once done

This commit is contained in:
j 2015-10-13 09:45:34 +02:00
parent 96eabd9c8f
commit 718421988c

View file

@ -111,9 +111,11 @@ class Server(Resource):
oshash = parts[-1] oshash = parts[-1]
if len(oshash) == 16: if len(oshash) == 16:
path = self.media_path(oshash) path = self.media_path(oshash)
tmp = path + '.tmp.webm'
ox.makedirs(os.path.dirname(path)) ox.makedirs(os.path.dirname(path))
with open(path, 'wb') as f: with open(tmp, 'wb') as f:
shutil.copyfileobj(request.content, f) shutil.copyfileobj(request.content, f)
shutil.move(tmp, path)
self.update_status(oshash, 'done') self.update_status(oshash, 'done')
self.upload.put(oshash) self.upload.put(oshash)
return self.render_json(request, { return self.render_json(request, {