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
87cebf99
Commit
87cebf99
authored
Sep 09, 2014
by
lister
Committed by
Jon Yurek
Sep 12, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update attachment.rb
Add explicit unlink to intermediate files from processors.
parent
6a5b30cf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
lib/paperclip/attachment.rb
+13
-2
No files found.
lib/paperclip/attachment.rb
View file @
87cebf99
...
...
@@ -515,9 +515,14 @@ module Paperclip
def
post_process_style
(
name
,
style
)
#:nodoc:
begin
raise
RuntimeError
.
new
(
"Style
#{
name
}
has no processors defined."
)
if
style
.
processors
.
blank?
intermediate_files
=
[]
@queued_for_write
[
name
]
=
style
.
processors
.
inject
(
@queued_for_write
[
:original
])
do
|
file
,
processor
|
Paperclip
.
processor
(
processor
).
make
(
file
,
style
.
processor_options
,
self
)
file
=
Paperclip
.
processor
(
processor
).
make
(
file
,
style
.
processor_options
,
self
)
intermediate_files
<<
file
file
end
unadapted_file
=
@queued_for_write
[
name
]
@queued_for_write
[
name
]
=
Paperclip
.
io_adapters
.
for
(
@queued_for_write
[
name
])
unadapted_file
.
close
if
unadapted_file
.
respond_to?
(
:close
)
...
...
@@ -525,6 +530,8 @@ module Paperclip
rescue
Paperclip
::
Error
=>
e
log
(
"An error was received while processing:
#{
e
.
inspect
}
"
)
(
@errors
[
:processing
]
||=
[])
<<
e
.
message
if
@options
[
:whiny
]
ensure
unlink_files
(
intermediate_files
)
end
end
...
...
@@ -565,7 +572,11 @@ module Paperclip
# called by storage after the writes are flushed and before @queued_for_write is cleared
def
after_flush_writes
@queued_for_write
.
each
do
|
style
,
file
|
unlink_files
(
@queued_for_write
.
values
)
end
def
unlink_files
(
files
)
Array
(
files
).
each
do
|
file
|
file
.
close
unless
file
.
closed?
file
.
unlink
if
file
.
respond_to?
(
:unlink
)
&&
file
.
path
.
present?
&&
File
.
exist?
(
file
.
path
)
end
...
...
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