Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore ftp error when deleting an non-existing file #29

Merged
merged 1 commit into from
Jul 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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