Skip to content

Commit

Permalink
Exceptions will bubble up to the application rather than being shallo…
Browse files Browse the repository at this point in the history
…wed at upload time
  • Loading branch information
dncrht committed Aug 12, 2017
1 parent 6c65f31 commit af0c03c
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions lib/paperclip/storage/imgur.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,12 @@ def exists?(style_name = default_style)
end

def flush_writes
@queued_for_write.each do |style, file| #style is 'original' etc...

begin
image = imgur_session.image.image_upload(file)
image_id = image.id
rescue
# Sometimes there are API or network errors.
# In this cases, we don't store anything.
image_id = nil
end
@queued_for_write.each do |style, file| # 'style' is 'original' etc…
image = imgur_session.image.image_upload(file)

# We cannot use update_attribute because it internally calls save, and save calls
# flush_writes again, and it will end up in a stack overflow due excessive recursion
instance.update_column :"#{name}_#{:file_name}", image_id
instance.update_column :"#{name}_#{:file_name}", image.id
end
after_flush_writes
@queued_for_write = {}
Expand Down

0 comments on commit af0c03c

Please sign in to comment.