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
0bd30e22
Commit
0bd30e22
authored
Jan 31, 2018
by
Michael Raidel
Committed by
Sid Raval
Mar 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix fallback when symlink in AbstractAdapter#link_or_copy_file fails
parent
2f4015de
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletions
+38
-1
lib/paperclip/io_adapters/abstract_adapter.rb
+3
-1
spec/paperclip/io_adapters/abstract_adapter_spec.rb
+35
-0
No files found.
lib/paperclip/io_adapters/abstract_adapter.rb
View file @
0bd30e22
...
@@ -62,7 +62,9 @@ module Paperclip
...
@@ -62,7 +62,9 @@ module Paperclip
@destination
.
close
@destination
.
close
@destination
.
open
.
binmode
@destination
.
open
.
binmode
rescue
Errno
::
EXDEV
,
Errno
::
EPERM
,
Errno
::
ENOENT
,
Errno
::
EEXIST
=>
e
rescue
Errno
::
EXDEV
,
Errno
::
EPERM
,
Errno
::
ENOENT
,
Errno
::
EEXIST
=>
e
Paperclip
.
log
(
"Link failed with
#{
e
.
message
}
; copying link
#{
src
}
to
#{
dest
}
"
)
Paperclip
.
log
(
"Link failed with
#{
e
.
message
}
; copying link
#{
src
}
to
#{
dest
}
"
)
FileUtils
.
cp
(
src
,
dest
)
FileUtils
.
cp
(
src
,
dest
)
@destination
.
close
@destination
.
close
@destination
.
open
.
binmode
@destination
.
open
.
binmode
...
...
spec/paperclip/io_adapters/abstract_adapter_spec.rb
View file @
0bd30e22
...
@@ -98,4 +98,39 @@ describe Paperclip::AbstractAdapter do
...
@@ -98,4 +98,39 @@ describe Paperclip::AbstractAdapter do
expect
{
subject
.
original_filename
=
nil
}.
not_to
raise_error
expect
{
subject
.
original_filename
=
nil
}.
not_to
raise_error
end
end
end
end
context
"#link_or_copy_file"
do
class
TestLinkOrCopyAdapter
<
Paperclip
::
AbstractAdapter
public
:copy_to_tempfile
,
:destination
end
subject
{
TestLinkOrCopyAdapter
.
new
(
nil
)
}
let
(
:body
)
{
"body"
}
let
(
:file
)
do
t
=
Tempfile
.
new
(
"destination"
)
t
.
print
(
body
)
t
.
rewind
t
end
after
do
file
.
close
file
.
unlink
end
it
"should be able to read the file"
do
expect
(
subject
.
copy_to_tempfile
(
file
).
read
).
to
eq
(
body
)
end
it
"should be able to reopen the file after symlink has failed"
do
FileUtils
.
expects
(
:ln
).
raises
(
Errno
::
EXDEV
)
# after the failed symlink the file reports a size of zero
# which makes it necessary to reopen it
# we simulate this condition by closing the file
subject
.
destination
.
close
expect
(
subject
.
copy_to_tempfile
(
file
).
read
).
to
eq
(
body
)
end
end
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