Skip to content

Commit

Permalink
Use atomic_move to put the file, rather than shelling out
Browse files Browse the repository at this point in the history
  • Loading branch information
jimi-c committed Oct 1, 2013
1 parent 8a3f8b7 commit 344d8d5
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions library/utilities/accelerate
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,7 @@ class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):

if final_path:
log("moving %s to %s" % (out_path, final_path))
args = ['sudo','cp',out_path,final_path]
rc, stdout, stderr = self.server.module.run_command(args, close_fds=True)
if rc != 0:
return dict(failed=True, stdout="failed to copy the file into position with sudo")
args = ['sudo','chown',final_user,out_path,final_path]
rc, stdout, stderr = self.server.module.run_command(args, close_fds=True)
if rc != 0:
return dict(failed=True, stdout="failed to chown the file via sudo")
self.server.module.atomic_move(out_path, final_path)
return dict()

def daemonize(module, password, port, minutes):
Expand Down

0 comments on commit 344d8d5

Please sign in to comment.