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
33ba2fd2
Commit
33ba2fd2
authored
May 09, 2018
by
Akihiko Odaki
Committed by
Sid Raval
May 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reopen file even when copying instead of linking (#2545)
parent
2c0760b5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
lib/paperclip/io_adapters/abstract_adapter.rb
+3
-2
spec/paperclip/io_adapters/abstract_adapter_spec.rb
+28
-0
No files found.
lib/paperclip/io_adapters/abstract_adapter.rb
View file @
33ba2fd2
...
...
@@ -57,15 +57,16 @@ module Paperclip
end
def
link_or_copy_file
(
src
,
dest
)
begin
Paperclip
.
log
(
"Trying to link
#{
src
}
to
#{
dest
}
"
)
FileUtils
.
ln
(
src
,
dest
,
force:
true
)
# overwrite existing
@destination
.
close
@destination
.
open
.
binmode
rescue
Errno
::
EXDEV
,
Errno
::
EPERM
,
Errno
::
ENOENT
,
Errno
::
EEXIST
=>
e
Paperclip
.
log
(
"Link failed with
#{
e
.
message
}
; copying link
#{
src
}
to
#{
dest
}
"
)
FileUtils
.
cp
(
src
,
dest
)
end
@destination
.
close
@destination
.
open
.
binmode
end
...
...
spec/paperclip/io_adapters/abstract_adapter_spec.rb
View file @
33ba2fd2
...
...
@@ -93,6 +93,34 @@ describe Paperclip::AbstractAdapter do
end
end
context
"#copy_to_tempfile"
do
around
do
|
example
|
FileUtils
.
module_eval
do
class
<<
self
alias
paperclip_ln
ln
def
ln
(
*
)
raise
Errno
::
EXDEV
end
end
end
example
.
run
FileUtils
.
module_eval
do
class
<<
self
alias
ln
paperclip_ln
undef
paperclip_ln
end
end
end
it
"should return a readable file even when linking fails"
do
src
=
open
(
fixture_file
(
"5k.png"
),
"rb"
)
expect
(
subject
.
send
(
:copy_to_tempfile
,
src
).
read
).
to
eq
src
.
read
end
end
context
"#original_filename="
do
it
"should not fail with a nil original filename"
do
expect
{
subject
.
original_filename
=
nil
}.
not_to
raise_error
...
...
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