From: Tom Hughes Date: Mon, 13 Oct 2008 23:27:49 +0000 (+0000) Subject: Fix race condition adding traces. Closes #1201. X-Git-Tag: live~7662 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/b105304a1b504827a86a93f3e8ad33abbbc5b1fc?hp=0d8e4b4337e9b94b6a9ed85095005a779f69583c Fix race condition adding traces. Closes #1201. --- diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 899df05df..f0e1fe7cc 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -306,10 +306,9 @@ private @trace.user = @user @trace.timestamp = Time.now - if @trace.save - FileUtils.mv(filename, @trace.trace_name) - else - FileUtils.rm_f(filename) + FileUtils.mv(filename, @trace.trace_name) + unless @trace.save + FileUtils.rm_f(@trace.trace_name) end end