Skip to content
Browse files

Fixing gemspec, adding mutex around other part of code that uses Acts…

…AsArchive.disabled
  • Loading branch information...
1 parent fab8876 commit d1a42dffadd1dc6490d4ec0f437b1e1c2d7dbea3 @winton committed Jan 13, 2011
Showing with 9 additions and 6 deletions.
  1. +1 −1 config/gemspec.yml
  2. +8 −5 lib/acts_as_archive.rb
View
2 config/gemspec.yml
@@ -9,4 +9,4 @@ description: Don't delete your records, move them to a different table. Like act
dependencies:
- also_migrate
- mover
-development_dependencies: nil
+development_dependencies: null
View
13 lib/acts_as_archive.rb
@@ -173,12 +173,15 @@ def self.included(base)
module InstanceMethods
def delete_sql_with_archive(sql, name = nil)
- unless ActsAsArchive.disabled
- from, where = /DELETE FROM (.+)/i.match(sql)[1].split(/\s+WHERE\s+/i, 2)
- from = from.strip.gsub(/`/, '').split(/\s*,\s*/)
+ @mutex ||= Mutex.new
+ @mutex.synchronize do
+ unless ActsAsArchive.disabled
+ from, where = /DELETE FROM (.+)/i.match(sql)[1].split(/\s+WHERE\s+/i, 2)
+ from = from.strip.gsub(/`/, '').split(/\s*,\s*/)
- ActsAsArchive.find(from).each do |config|
- ActsAsArchive.move(config, where)
+ ActsAsArchive.find(from).each do |config|
+ ActsAsArchive.move(config, where)
+ end
end
end

0 comments on commit d1a42df

Please sign in to comment.
Something went wrong with that request. Please try again.