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
d46a1afe
Commit
d46a1afe
authored
Jun 15, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewind tempfiles after get saved to storages
Re-fix of #838, #766, #911
parent
cdf85a20
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
0 deletions
+16
-0
lib/paperclip/storage/fog.rb
+2
-0
lib/paperclip/storage/s3.rb
+2
-0
test/storage/fog_test.rb
+6
-0
test/storage/s3_test.rb
+6
-0
No files found.
lib/paperclip/storage/fog.rb
View file @
d46a1afe
...
@@ -90,6 +90,8 @@ module Paperclip
...
@@ -90,6 +90,8 @@ module Paperclip
retried
=
true
retried
=
true
directory
.
save
directory
.
save
retry
retry
ensure
file
.
rewind
end
end
end
end
...
...
lib/paperclip/storage/s3.rb
View file @
d46a1afe
...
@@ -310,6 +310,8 @@ module Paperclip
...
@@ -310,6 +310,8 @@ module Paperclip
rescue
AWS
::
S3
::
Errors
::
NoSuchBucket
=>
e
rescue
AWS
::
S3
::
Errors
::
NoSuchBucket
=>
e
create_bucket
create_bucket
retry
retry
ensure
file
.
rewind
end
end
end
end
...
...
test/storage/fog_test.rb
View file @
d46a1afe
...
@@ -111,6 +111,12 @@ class FogTest < Test::Unit::TestCase
...
@@ -111,6 +111,12 @@ class FogTest < Test::Unit::TestCase
directory
.
destroy
directory
.
destroy
end
end
should
"be rewinded after flush_writes"
do
files
=
@dummy
.
avatar
.
queued_for_write
.
map
{
|
style
,
file
|
file
}
@dummy
.
save
assert
files
.
none?
(
&
:eof?
),
"Expect all the files to be rewinded."
end
should
"pass the content type to the Fog::Storage::AWS::Files instance"
do
should
"pass the content type to the Fog::Storage::AWS::Files instance"
do
Fog
::
Storage
::
AWS
::
Files
.
any_instance
.
expects
(
:create
).
with
do
|
hash
|
Fog
::
Storage
::
AWS
::
Files
.
any_instance
.
expects
(
:create
).
with
do
|
hash
|
hash
[
:content_type
]
hash
[
:content_type
]
...
...
test/storage/s3_test.rb
View file @
d46a1afe
...
@@ -569,6 +569,12 @@ class S3Test < Test::Unit::TestCase
...
@@ -569,6 +569,12 @@ class S3Test < Test::Unit::TestCase
assert_match
%r{^http://s3
\.
amazonaws
\.
com/testing/avatars/original/5k
\.
png}
,
@dummy
.
avatar
.
url
assert_match
%r{^http://s3
\.
amazonaws
\.
com/testing/avatars/original/5k
\.
png}
,
@dummy
.
avatar
.
url
end
end
should
"be rewinded after flush_writes"
do
files
=
@dummy
.
avatar
.
queued_for_write
.
map
{
|
style
,
file
|
file
.
tap
(
&
:read
)
}
@dummy
.
save
assert
files
.
none?
(
&
:eof?
),
"Expect all the files to be rewinded."
end
context
"and saved"
do
context
"and saved"
do
setup
do
setup
do
object
=
stub
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