]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/relation.rb
Moved a bunch of time functions into UTC. Fixes bugs which we only see for 4 hours...
[rails.git] / app / models / relation.rb
index 64af4ecc1eb9d59eff27e8b46d292f3a2aa560f6..a8789bc78707029a060a7db3f2de2d50cba86846 100644 (file)
@@ -33,7 +33,7 @@ class Relation < ActiveRecord::Base
       doc.find('//osm/relation').each do |pt|
         return Relation.from_xml_node(pt, create)
       end
       doc.find('//osm/relation').each do |pt|
         return Relation.from_xml_node(pt, create)
       end
-    rescue LibXML::XML::Error => ex
+    rescue LibXML::XML::Error, ArgumentError => ex
       raise OSM::APIBadXMLError.new("relation", xml, ex.message)
     end
   end
       raise OSM::APIBadXMLError.new("relation", xml, ex.message)
     end
   end
@@ -51,7 +51,7 @@ class Relation < ActiveRecord::Base
     # The follow block does not need to be executed because they are dealt with 
     # in create_with_history, update_from and delete_with_history
     if create
     # The follow block does not need to be executed because they are dealt with 
     # in create_with_history, update_from and delete_with_history
     if create
-      relation.timestamp = Time.now
+      relation.timestamp = Time.now.getutc
       relation.visible = true
       relation.version = 0
     else
       relation.visible = true
       relation.version = 0
     else
@@ -253,6 +253,7 @@ class Relation < ActiveRecord::Base
       raise OSM::APIPreconditionFailedError.new
     end
     self.changeset_id = new_relation.changeset_id
       raise OSM::APIPreconditionFailedError.new
     end
     self.changeset_id = new_relation.changeset_id
+    self.changeset = new_relation.changeset
     self.tags = new_relation.tags
     self.members = new_relation.members
     self.visible = true
     self.tags = new_relation.tags
     self.members = new_relation.members
     self.visible = true
@@ -333,7 +334,7 @@ class Relation < ActiveRecord::Base
       # changed then we have to monitor their before and after state.
       tags_changed = false
 
       # changed then we have to monitor their before and after state.
       tags_changed = false
 
-      t = Time.now
+      t = Time.now.getutc
       self.version += 1
       self.timestamp = t
       self.save!
       self.version += 1
       self.timestamp = t
       self.save!
@@ -372,6 +373,10 @@ class Relation < ActiveRecord::Base
         tag.id = self.id
         tag.save!
       end
         tag.id = self.id
         tag.save!
       end
+      
+      # reload, so that all of the members are accessible in their
+      # new state.
+      self.reload
 
       # same pattern as before, but this time we're collecting the
       # changed members in an array, as the bounding box updates for
 
       # same pattern as before, but this time we're collecting the
       # changed members in an array, as the bounding box updates for