Repository navigation
Reopen file even when copying instead of linking - #2545
Conversation
| Paperclip.log("Link failed with #{e.message}; copying link #{src} to #{dest}") | ||
| FileUtils.cp(src, dest) | ||
| ensure | ||
| @destination.close |
There was a problem hiding this comment.
Use 2 (not 3) spaces for indentation.
| 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) | ||
| ensure |
There was a problem hiding this comment.
ensure at 65, 3 is not aligned with end at 68, 4.
| Paperclip.log("Trying to link #{src} to #{dest}") | ||
| FileUtils.ln(src, dest, force: true) # overwrite existing | ||
| rescue Errno::EXDEV, Errno::EPERM, Errno::ENOENT, Errno::EEXIST => e | ||
| Paperclip.log("Link failed with #{e.message}; copying link #{src} to #{dest}") |
There was a problem hiding this comment.
This is not introduced by my change and should be addressed in another pull request if it is problematic.
| end | ||
| end | ||
|
|
||
| it 'should return a readable file even when linking fails' do |
There was a problem hiding this comment.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
| end | ||
| end | ||
|
|
||
| context '#copy_to_tempfile' do |
There was a problem hiding this comment.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
| end | ||
|
|
||
| it "should return a readable file even when linking fails" do | ||
| src = open(fixture_file("5k.png"), "rb") |
There was a problem hiding this comment.
Security/Open: The use of Kernel#open is a serious security risk.
| FileUtils.ln(src, dest, force: true) # overwrite existing | ||
| rescue Errno::EXDEV, Errno::EPERM, Errno::ENOENT, Errno::EEXIST => e | ||
| Paperclip.log( | ||
| "Link failed with #{e.message}; copying link #{src} to #{dest}" |
There was a problem hiding this comment.
Style/TrailingCommaInArguments: Put a comma after the last parameter of a multiline method call.
This is necessary for: