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
87bd86cc
Commit
87bd86cc
authored
Apr 22, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolved mvanholstyn's open file fixes with current code
parent
f79dadce
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
26 deletions
+10
-26
lib/paperclip/attachment.rb
+3
-3
lib/paperclip/storage.rb
+3
-3
tasks/paperclip_tasks.rake
+3
-2
test/test_attachment.rb
+0
-17
test/test_integration.rb
+1
-1
No files found.
lib/paperclip/attachment.rb
View file @
87bd86cc
...
...
@@ -186,9 +186,9 @@ module Paperclip
begin
dimensions
,
format
=
args
@queued_for_write
[
name
]
=
Thumbnail
.
make
(
@queued_for_write
[
:original
],
dimensions
,
format
,
@whiny_thumnails
)
dimensions
,
format
,
@whiny_thumnails
)
rescue
Errno
::
ENOENT
=>
e
@errors
<<
"could not be processed because the file does not exist."
rescue
PaperclipError
=>
e
...
...
lib/paperclip/storage.rb
View file @
87bd86cc
...
...
@@ -16,7 +16,7 @@ module Paperclip
# Returns representation of the data of the file assigned to the given
# style, in the format most representative of the current storage.
def
to_file
style
=
default_style
File
.
new
(
path
(
style
))
if
exists?
(
style
)
@queued_for_write
[
style
]
||
(
File
.
new
(
path
(
style
))
if
exists?
(
style
)
)
end
alias_method
:to_io
,
:to_file
...
...
@@ -35,7 +35,7 @@ module Paperclip
begin
FileUtils
.
rm
(
path
)
if
File
.
exist?
(
path
)
rescue
Errno
::
ENOENT
=>
e
# ignore
them
# ignore
file-not-found, let everything else pass
end
end
@queued_for_delete
=
[]
...
...
@@ -74,7 +74,7 @@ module Paperclip
# Returns representation of the data of the file assigned to the given
# style, in the format most representative of the current storage.
def
to_file
style
=
default_style
@s3_bucket
.
key
(
path
(
style
))
@
queued_for_write
[
style
]
||
@
s3_bucket
.
key
(
path
(
style
))
end
alias_method
:to_io
,
:to_file
...
...
tasks/paperclip_tasks.rake
View file @
87bd86cc
def
obtain_class
class_name
=
ENV
[
'CLASS'
]
||
ENV
[
'class'
]
raise
"Must specify CLASS"
unless
class_name
@klass
=
Object
.
const_get
(
class_name
)
end
def
obtain_attachments
name
=
ENV
[
'ATTACHMENT'
]
||
ENV
[
'attachment'
]
raise
"Class
#{
@klass
.
name
}
has no attachments specified"
unless
@klass
.
respond_to?
(
:attachment_names
)
if
!
name
.
blank?
&&
@klass
.
attachment_names
.
include?
(
name
)
[
name
]
else
...
...
@@ -16,11 +18,10 @@ namespace :paperclip do
desc
"Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)"
task
:refresh
=>
:environment
do
klass
=
obtain_class
instances
=
klass
.
find
(
:all
)
names
=
obtain_attachments
puts
"Regenerating thumbnails for
#{
instances
.
length
}
instances of
#{
klass
.
name
}
:"
instances
.
each
do
|
instance
|
klass
.
find
(
:all
)
.
each
do
|
instance
|
names
.
each
do
|
name
|
result
=
if
instance
.
send
(
"
#{
name
}
?"
)
instance
.
send
(
name
).
send
(
"post_process"
)
...
...
test/test_attachment.rb
View file @
87bd86cc
...
...
@@ -195,23 +195,6 @@ class AttachmentTest < Test::Unit::TestCase
@existing_names
.
each
{
|
f
|
assert
!
File
.
exists?
(
f
)
}
end
end
context
"and deleted"
do
setup
do
@existing_names
=
@attachment
.
styles
.
keys
.
collect
do
|
style
|
@attachment
.
path
(
style
)
end
@instance
.
expects
(
:[]=
).
with
(
:test_file_name
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_content_type
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_file_size
,
nil
)
@attachment
.
assign
nil
@attachment
.
save
end
should
"delete the files"
do
@existing_names
.
each
{
|
f
|
assert
!
File
.
exists?
(
f
)
}
end
end
end
end
end
...
...
test/test_integration.rb
View file @
87bd86cc
...
...
@@ -223,7 +223,7 @@ class IntegrationTest < Test::Unit::TestCase
expected
=
@dummy
.
avatar
.
to_file
@dummy
.
avatar
=
"not a file"
assert
@dummy
.
valid?
assert_equal
expected
,
@dummy
.
avatar
.
to_fil
e
assert_equal
expected
.
full_name
,
@dummy
.
avatar
.
to_file
.
full_nam
e
@dummy
.
avatar
=
@bad_file
assert
!
@dummy
.
valid?
...
...
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