]> git.openstreetmap.org Git - rails.git/commitdiff
Split the transaction used for ways so that we recover more cleanly
authorTom Hughes <tom@compton.nu>
Fri, 31 Aug 2007 23:10:33 +0000 (23:10 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 31 Aug 2007 23:10:33 +0000 (23:10 +0000)
without leaving rubbish in the database.

app/models/way.rb

index d86d82de684058ce601c1eb81b99ee3197088be5..c844c1518a4b22f39f1d23a645a8ecbc9d9e9fd6 100644 (file)
@@ -147,7 +147,9 @@ class Way < ActiveRecord::Base
       t = Time.now
       self.timestamp = t
       self.save!
+    end
 
+    WayTag.transaction do
       tags = self.tags
 
       WayTag.delete_all(['id = ?', self.id])
@@ -159,7 +161,9 @@ class Way < ActiveRecord::Base
         tag.id = self.id
         tag.save!
       end
+    done
 
+    WaySegment.transaction do
       segs = self.segs
 
       WaySegment.delete_all(['id = ?', self.id])
@@ -173,11 +177,11 @@ class Way < ActiveRecord::Base
         seg.save!
         i += 1
       end
-
-      old_way = OldWay.from_way(self)
-      old_way.timestamp = t
-      old_way.save_with_dependencies!
     end
+
+    old_way = OldWay.from_way(self)
+    old_way.timestamp = t
+    old_way.save_with_dependencies!
   end
 
   def preconditions_ok?