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
4e076813
Commit
4e076813
authored
Jan 04, 2012
by
Nathan Hyde
Committed by
Jon Yurek
Jan 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't calculate fingerprint when fingerprint can not be stored.
parent
7b70fa48
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
lib/paperclip/attachment.rb
+3
-2
test/attachment_test.rb
+8
-1
No files found.
lib/paperclip/attachment.rb
View file @
4e076813
...
...
@@ -106,11 +106,12 @@ module Paperclip
return
nil
if
uploaded_file
.
nil?
uploaded_filename
||=
uploaded_file
.
original_filename
stores_fingerprint
=
@instance
.
respond_to?
(
"
#{
name
}
_fingerprint"
.
to_sym
)
@queued_for_write
[
:original
]
=
to_tempfile
(
uploaded_file
)
instance_write
(
:file_name
,
uploaded_filename
.
strip
)
instance_write
(
:content_type
,
uploaded_file
.
content_type
.
to_s
.
strip
)
instance_write
(
:file_size
,
uploaded_file
.
size
.
to_i
)
instance_write
(
:fingerprint
,
generate_fingerprint
(
uploaded_file
)
)
instance_write
(
:fingerprint
,
stores_fingerprint
?
generate_fingerprint
(
uploaded_file
)
:
false
)
instance_write
(
:updated_at
,
Time
.
now
)
@dirty
=
true
...
...
@@ -119,7 +120,7 @@ module Paperclip
# Reset the file size if the original file was reprocessed.
instance_write
(
:file_size
,
@queued_for_write
[
:original
].
size
.
to_i
)
instance_write
(
:fingerprint
,
generate_fingerprint
(
@queued_for_write
[
:original
]))
instance_write
(
:fingerprint
,
generate_fingerprint
(
@queued_for_write
[
:original
]))
if
stores_fingerprint
ensure
uploaded_file
.
close
if
close_uploaded_file
end
...
...
test/attachment_test.rb
View file @
4e076813
...
...
@@ -997,7 +997,14 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal
now
.
to_i
,
@dummy
.
avatar
.
updated_at
end
end
should
"not calculate fingerprint without fingerprint column"
do
assert_equal
false
,
@dummy
.
respond_to?
(
:avatar_fingerprint
)
@dummy
.
avatar
=
@file
@dummy
.
save
assert_nil
@dummy
.
avatar
.
fingerprint
end
context
"and avatar_content_type column"
do
setup
do
ActiveRecord
::
Base
.
connection
.
add_column
:dummies
,
:avatar_content_type
,
:string
...
...
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