diff --git a/lib/paperclip/storage/ftp/server.rb b/lib/paperclip/storage/ftp/server.rb index 0094fab..7588566 100644 --- a/lib/paperclip/storage/ftp/server.rb +++ b/lib/paperclip/storage/ftp/server.rb @@ -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) diff --git a/spec/paperclip/storage/ftp/server_spec.rb b/spec/paperclip/storage/ftp/server_spec.rb index 15ed2a1..b79fe68 100644 --- a/spec/paperclip/storage/ftp/server_spec.rb +++ b/spec/paperclip/storage/ftp/server_spec.rb @@ -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