Fix race condition when auto-moving implications
This commit is contained in:
@@ -145,8 +145,14 @@ class TagAlias < ActiveRecord::Base
|
|||||||
implications.each do |ti|
|
implications.each do |ti|
|
||||||
ti.antecedent_name = self.consequent_name
|
ti.antecedent_name = self.consequent_name
|
||||||
success = ti.save
|
success = ti.save
|
||||||
if !success && ti.errors.full_messages.join("; ") =~ /Cannot implicate a tag to itself/
|
if !success
|
||||||
ti.destroy
|
case ti.errors.full_messages.join("; ")
|
||||||
|
when /Cannot implicate a tag to itself/
|
||||||
|
ti.destroy
|
||||||
|
when /Consequent tag must not be aliased to another tag/
|
||||||
|
ti.consequent_name = TagAlias.to_aliased(ti.consequent_name).first
|
||||||
|
ti.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -154,8 +160,14 @@ class TagAlias < ActiveRecord::Base
|
|||||||
implications.each do |ti|
|
implications.each do |ti|
|
||||||
ti.consequent_name = self.consequent_name
|
ti.consequent_name = self.consequent_name
|
||||||
success = ti.save
|
success = ti.save
|
||||||
if !success && ti.errors.full_messages.join("; ") =~ /Cannot implicate a tag to itself/
|
if !success
|
||||||
ti.destroy
|
case ti.errors.full_messages.join("; ")
|
||||||
|
when /Cannot implicate a tag to itself/
|
||||||
|
ti.destroy
|
||||||
|
when /Antecedent tag must not be aliased to another tag/
|
||||||
|
ti.antecedent_name = TagAlias.to_aliased(ti.antecedent_name).first
|
||||||
|
ti.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user