lib/tasks/import.rake in provider_taxonomy-0.1.6 vs lib/tasks/import.rake in provider_taxonomy-0.1.7
- old
+ new
@@ -8,13 +8,24 @@
task import_provider_taxonomy: :environment do
require 'csv'
require 'open-uri'
def download(url, dest)
- open(url) do |u|
- f = File.open(dest, 'wb')
- f.write(u.read)
- f.close
+ retry_count = 10
+ begin
+ open(url) do |u|
+ f = File.open(dest, 'wb')
+ f.write(u.read)
+ f.close
+ end
+ rescue SocketError
+ retry_count -= 1
+ if retry_count > 0
+ sleep(1.0)
+ retry
+ else
+ raise
+ end
end
if File.exist?(dest)
puts "Taxonomy file downloaded from: #{url}"
else