Skip to content

Commit

Permalink
Merge pull request #29 from mlankenau/rescue_from_perm_errors
Browse files Browse the repository at this point in the history
Ignore ftp error when deleting an non-existing file
  • Loading branch information
boosty committed Jul 21, 2015
2 parents b0f9df6 + 061ae9f commit 8af02c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/paperclip/storage/ftp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def put_file(local_file_path, remote_file_path)

def delete_file(remote_file_path)
connection.delete(remote_file_path)
rescue Net::FTPPermError
# This happens if the file is already deleted
end

def rmdir_p(dir_path)
Expand Down
6 changes: 6 additions & 0 deletions spec/paperclip/storage/ftp/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
server.connection.should_receive(:delete).with("/files/original.jpg")
server.delete_file("/files/original.jpg")
end

it 'rescues from Net::FTPPermError' do
server.connection.should_receive(:delete).with('/files/original.jpg')
.and_raise Net::FTPPermError
expect { server.delete_file('/files/original.jpg') }.to_not raise_error
end
end

context "#rmdir_p" do
Expand Down

0 comments on commit 8af02c9

Please sign in to comment.