Skip to content

Commit

Permalink
Setting the FILE_processing variable immediately after the save call
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertg committed Aug 31, 2011
1 parent 14f2109 commit 907087d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/delayed_paperclip.rb
Expand Up @@ -60,15 +60,8 @@ module InstanceMethods
# setting each inididual NAME_processing to true, skipping the ActiveModel dirty setter
# Then immediately push the state to the database
def mark_enqueue_delayed_processing
processing = []
(@_enqued_for_processing || []).each do |name|
if self.attributes.has_key? "#{name}_processing"
write_attribute("#{name}_processing", true)
processing << name
end
end
unless processing.empty?
updates = processing.collect{|n| "#{n}_processing = :true" }.join(", ")
unless @_enqued_for_processing_with_processing.blank? # catches nil and empy arrays
updates = @_enqued_for_processing_with_processing.collect{|n| "#{n}_processing = :true" }.join(", ")
updates = ActiveRecord::Base.send(:sanitize_sql_array, [updates, {:true => true}])
self.class.update_all(updates, "id = #{self.id}")
end
Expand All @@ -81,6 +74,7 @@ def enqueue_delayed_processing
(@_enqued_for_processing || []).each do |name|
enqueue_post_processing_for(name)
end
@_enqued_for_processing_with_processing = []
@_enqued_for_processing = []
end

Expand All @@ -96,6 +90,11 @@ def attachment_for name
end

def prepare_enqueueing_for name
if self.attributes.has_key? "#{name}_processing"
write_attribute("#{name}_processing", true)
@_enqued_for_processing_with_processing ||= []
@_enqued_for_processing_with_processing << name
end
@_enqued_for_processing ||= []
@_enqued_for_processing << name
end
Expand Down

0 comments on commit 907087d

Please sign in to comment.