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
281a7553
Commit
281a7553
authored
Aug 31, 2011
by
Mike Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'features/tempfile_cleanup' of
https://github.com/danielevans/paperclip
parents
630c6341
89ecde48
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
0 deletions
+42
-0
lib/paperclip/attachment.rb
+8
-0
lib/paperclip/storage/filesystem.rb
+3
-0
lib/paperclip/storage/fog.rb
+3
-0
lib/paperclip/storage/s3.rb
+3
-0
test/fog_test.rb
+8
-0
test/storage_test.rb
+17
-0
No files found.
lib/paperclip/attachment.rb
View file @
281a7553
...
...
@@ -420,5 +420,13 @@ module Paperclip
end
end
# called by storage after the writes are flushed and before @queued_for_writes is cleared
def
after_flush_writes
@queued_for_write
.
each
do
|
style
,
file
|
file
.
close
unless
file
.
closed?
file
.
unlink
if
file
.
respond_to?
(
:unlink
)
&&
file
.
path
.
present?
&&
File
.
exist?
(
file
.
path
)
end
end
end
end
lib/paperclip/storage/filesystem.rb
View file @
281a7553
...
...
@@ -46,6 +46,9 @@ module Paperclip
end
FileUtils
.
chmod
(
0666
&~
File
.
umask
,
path
(
style_name
))
end
after_flush_writes
# allows attachment to clean up temp files
@queued_for_write
=
{}
end
...
...
lib/paperclip/storage/fog.rb
View file @
281a7553
...
...
@@ -82,6 +82,9 @@ module Paperclip
retry
end
end
after_flush_writes
# allows attachment to clean up temp files
@queued_for_write
=
{}
end
...
...
lib/paperclip/storage/s3.rb
View file @
281a7553
...
...
@@ -196,6 +196,9 @@ module Paperclip
raise
end
end
after_flush_writes
# allows attachment to clean up temp files
@queued_for_write
=
{}
end
...
...
test/fog_test.rb
View file @
281a7553
...
...
@@ -57,6 +57,14 @@ class FogTest < Test::Unit::TestCase
assert_equal
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../public/avatars/5k.png"
)),
@dummy
.
avatar
.
path
end
should
"clean up file objects"
do
File
.
stubs
(
:exist?
).
returns
(
true
)
Paperclip
::
Tempfile
.
any_instance
.
expects
(
:close
).
at_least_once
()
Paperclip
::
Tempfile
.
any_instance
.
expects
(
:unlink
).
at_least_once
()
@dummy
.
save!
end
end
setup
do
...
...
test/storage_test.rb
View file @
281a7553
...
...
@@ -29,6 +29,14 @@ class StorageTest < Test::Unit::TestCase
@dummy
.
save
assert
File
.
exists?
(
@dummy
.
avatar
.
path
(
:thumbnail
))
end
should
"clean up file objects"
do
File
.
stubs
(
:exist?
).
returns
(
true
)
Paperclip
::
Tempfile
.
any_instance
.
expects
(
:close
).
at_least_once
()
Paperclip
::
Tempfile
.
any_instance
.
expects
(
:unlink
).
at_least_once
()
@dummy
.
save!
end
end
context
"Parsing S3 credentials"
do
...
...
@@ -349,6 +357,15 @@ class StorageTest < Test::Unit::TestCase
end
end
should
"delete tempfiles"
do
AWS
::
S3
::
S3Object
.
stubs
(
:store
).
with
(
@dummy
.
avatar
.
path
,
anything
,
'testing'
,
:content_type
=>
'image/png'
,
:access
=>
:public_read
)
File
.
stubs
(
:exist?
).
returns
(
true
)
Paperclip
::
Tempfile
.
any_instance
.
expects
(
:close
).
at_least_once
()
Paperclip
::
Tempfile
.
any_instance
.
expects
(
:unlink
).
at_least_once
()
@dummy
.
save!
end
context
"and saved without a bucket"
do
setup
do
class
AWS
::
S3
::
NoSuchBucket
<
AWS
::
S3
::
ResponseError
...
...
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