Skip to content

Instantly share code, notes, and snippets.

@hSATAC
Forked from scottwb/carrierwave_fog_hack.rb
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hSATAC/7c1659f607f53f2af2c5 to your computer and use it in GitHub Desktop.
Save hSATAC/7c1659f607f53f2af2c5 to your computer and use it in GitHub Desktop.
module CarrierWave
module Storage
class Fog
class File
alias :store_without_safety_net :store
def store(new_file)
retries_remaining = 3
begin
store_without_safety_net(new_file)
rescue Excon::Errors::SocketError => e
if e.inspect =~ /Connection reset by peer/
Rails.logger.error e.inspect
Rails.logger.error "Retrying... remaining time: #{retries_remaining}"
retries_remaining -= 1
if retries_remaining <= 0
raise
else
retry
end
else
raise
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment