Skip to content

Commit

Permalink
Merge pull request #23 from mattbeedle/mb/download-location-change
Browse files Browse the repository at this point in the history
USDA keep changing the &^%#^%$& download location
  • Loading branch information
mattbeedle authored Nov 15, 2016
2 parents bc0784f + a4b1a98 commit 9c8412e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/usda_nutrient_database/import/downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ def download_and_unzip

def path
[
'SP2UserFiles',
'Place',
'12354500',
'ARSUserFiles',
'80400525',
'Data',
version == 'sr28' ? 'SR' : nil,
version.upcase,
Expand Down Expand Up @@ -60,7 +59,7 @@ def connection

def final_path
look_ahead = connection.head(path)
if look_ahead.status == 302
if [302, 404].include?(look_ahead.status)
raise 'No location' unless look_ahead.headers['location']
URI.parse(look_ahead.headers['location']).path
else
Expand Down

0 comments on commit 9c8412e

Please sign in to comment.