Commit 56c30229 by Jon Yurek

Exponential Backup with 0.5s, not 500s

parent 5b22af36
......@@ -363,8 +363,8 @@ module Paperclip
retry
rescue AWS::S3::Errors::SlowDown
retries += 1
if retries <= 3
sleep((retries ** 2) * 500)
if retries <= 5
sleep((2 ** retries) * 0.5)
retry
else
raise
......
......@@ -717,7 +717,11 @@ describe Paperclip::Storage::S3 do
raises(AWS::S3::Errors::SlowDown.new(stub, stub(status: 503, body: "")))
expect {@dummy.save}.to raise_error(AWS::S3::Errors::SlowDown)
expect(@dummy.avatar).to have_received(:sleep).times(3)
expect(@dummy.avatar).to have_received(:sleep).with(1)
expect(@dummy.avatar).to have_received(:sleep).with(2)
expect(@dummy.avatar).to have_received(:sleep).with(4)
expect(@dummy.avatar).to have_received(:sleep).with(8)
expect(@dummy.avatar).to have_received(:sleep).with(16)
end
context "and saved" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment