Fix race condition adding traces. Closes #1201.
authorTom Hughes <tom@compton.nu>
Mon, 13 Oct 2008 23:27:49 +0000 (23:27 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 13 Oct 2008 23:27:49 +0000 (23:27 +0000)
app/controllers/trace_controller.rb

index 899df05dfc021d1d683012bfbb8b995f42579d04..f0e1fe7cc3881cbc9295a92ffc61b9036124210c 100644 (file)
@@ -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