]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/trace_controller.rb
Moved a bunch of time functions into UTC. Fixes bugs which we only see for 4 hours...
[rails.git] / app / controllers / trace_controller.rb
index 47041b4919fb2e25de18c0fbfdc08a3c96b7c1ab..c0a0b36b53274809f365638a9f4378bba2bba15c 100644 (file)
@@ -117,7 +117,7 @@ class TraceController < ApplicationController
                             :description => params[:trace][:description],
                             :public => params[:trace][:public],
                             :inserted => false, :user => @user,
-                            :timestamp => Time.now})
+                            :timestamp => Time.now.getutc})
         @trace.valid?
         @trace.errors.add(:gpx_file, "can't be blank")
       end
@@ -279,12 +279,20 @@ class TraceController < ApplicationController
 
   def api_create
     if request.post?
-      do_create(params[:file], params[:tags], params[:description], params[:public])
+      tags = params[:tags] || ""
+      description = params[:description] || ""
+      pub = params[:public] || false
+      
+      if params[:file].respond_to?(:read)
+        do_create(params[:file], tags, description, pub)
 
-      if @trace.id
-        render :text => @trace.id.to_s, :content_type => "text/plain"
-      elsif @trace.valid?
-        render :nothing => true, :status => :internal_server_error
+        if @trace.id
+          render :text => @trace.id.to_s, :content_type => "text/plain"
+        elsif @trace.valid?
+          render :nothing => true, :status => :internal_server_error
+        else
+          render :nothing => true, :status => :bad_request
+        end
       else
         render :nothing => true, :status => :bad_request
       end
@@ -305,7 +313,7 @@ private
                         :description => description, :public => public})
     @trace.inserted = false
     @trace.user = @user
-    @trace.timestamp = Time.now
+    @trace.timestamp = Time.now.getutc
 
     if @trace.save
       FileUtils.mv(filename, @trace.trace_name)