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
bd016009
Commit
bd016009
authored
Jan 15, 2016
by
Jon Moss
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2091 from mattbrictson/lazy-fingerprint
Skip calculating fingerprint when it is not used
parents
8667baac
53a386c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
lib/paperclip/attachment.rb
+4
-4
spec/paperclip/attachment_spec.rb
+6
-0
No files found.
lib/paperclip/attachment.rb
View file @
bd016009
...
@@ -427,7 +427,7 @@ module Paperclip
...
@@ -427,7 +427,7 @@ module Paperclip
def
assign_attributes
def
assign_attributes
@queued_for_write
[
:original
]
=
@file
@queued_for_write
[
:original
]
=
@file
assign_file_information
assign_file_information
assign_fingerprint
(
@file
.
fingerprint
)
assign_fingerprint
{
@file
.
fingerprint
}
assign_timestamps
assign_timestamps
end
end
...
@@ -437,9 +437,9 @@ module Paperclip
...
@@ -437,9 +437,9 @@ module Paperclip
instance_write
(
:file_size
,
@file
.
size
)
instance_write
(
:file_size
,
@file
.
size
)
end
end
def
assign_fingerprint
(
fingerprint
)
def
assign_fingerprint
if
instance_respond_to?
(
:fingerprint
)
if
instance_respond_to?
(
:fingerprint
)
instance_write
(
:fingerprint
,
fingerprint
)
instance_write
(
:fingerprint
,
yield
)
end
end
end
end
...
@@ -465,7 +465,7 @@ module Paperclip
...
@@ -465,7 +465,7 @@ module Paperclip
def
reset_file_if_original_reprocessed
def
reset_file_if_original_reprocessed
instance_write
(
:file_size
,
@queued_for_write
[
:original
].
size
)
instance_write
(
:file_size
,
@queued_for_write
[
:original
].
size
)
assign_fingerprint
(
@queued_for_write
[
:original
].
fingerprint
)
assign_fingerprint
{
@queued_for_write
[
:original
].
fingerprint
}
reset_updater
reset_updater
end
end
...
...
spec/paperclip/attachment_spec.rb
View file @
bd016009
...
@@ -1374,6 +1374,12 @@ describe Paperclip::Attachment do
...
@@ -1374,6 +1374,12 @@ describe Paperclip::Attachment do
end
end
it
"does not calculate fingerprint"
do
it
"does not calculate fingerprint"
do
Digest
::
MD5
.
stubs
(
:file
)
@dummy
.
avatar
=
@file
expect
(
Digest
::
MD5
).
to
have_received
(
:file
).
never
end
it
"does not assign fingerprint"
do
@dummy
.
avatar
=
@file
@dummy
.
avatar
=
@file
assert_nil
@dummy
.
avatar
.
fingerprint
assert_nil
@dummy
.
avatar
.
fingerprint
end
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