Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
e8c1dc8a
Commit
e8c1dc8a
authored
Aug 07, 2014
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backoff when we get a SlowDown error
parent
dca87ec5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
lib/paperclip/storage/s3.rb
+10
-1
spec/paperclip/storage/s3_spec.rb
+9
-0
No files found.
lib/paperclip/storage/s3.rb
View file @
e8c1dc8a
...
...
@@ -329,6 +329,7 @@ module Paperclip
def
flush_writes
#:nodoc:
@queued_for_write
.
each
do
|
style
,
file
|
retries
=
0
begin
log
(
"saving
#{
path
(
style
)
}
"
)
acl
=
@s3_permissions
[
style
]
||
@s3_permissions
[
:default
]
...
...
@@ -357,9 +358,17 @@ module Paperclip
write_options
.
merge!
(
@s3_headers
)
s3_object
(
style
).
write
(
file
,
write_options
)
rescue
AWS
::
S3
::
Errors
::
NoSuchBucket
=>
e
rescue
AWS
::
S3
::
Errors
::
NoSuchBucket
create_bucket
retry
rescue
AWS
::
S3
::
Errors
::
SlowDown
retries
+=
1
if
retries
<=
3
sleep
((
retries
**
2
)
*
500
)
retry
else
raise
end
ensure
file
.
rewind
end
...
...
spec/paperclip/storage/s3_spec.rb
View file @
e8c1dc8a
...
...
@@ -711,6 +711,15 @@ describe Paperclip::Storage::S3 do
"Expect all the files to be deleted."
end
it
"will retry to save again but back off on SlowDown"
do
@dummy
.
avatar
.
stubs
(
:sleep
)
AWS
::
S3
::
S3Object
.
any_instance
.
stubs
(
:write
).
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
)
end
context
"and saved"
do
before
do
object
=
stub
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment