Handle missing files/URLs gracefully.

If no version of a URL is found the importer just skips the URL now instead of throwing an error.
This commit is contained in:
Christoph Haas 2015-04-24 16:58:08 +02:00
parent 10ebc63dc1
commit f511dfbd56

View file

@ -39,7 +39,11 @@ module DebImporter
def i18n(component, language)
url = "#{@dist_url}/#{component}/i18n/Translation-en"
file = find_and_open_compressed_url(url)
return get_paragraphs(file)
if file
return get_paragraphs(file)
else
return []
end
end
# Look for the file or URL in various compressed formats
@ -68,9 +72,12 @@ module DebImporter
return file
rescue Errno::ENOENT
Rails.logger.error "URL #{url} could not be opened. Skipping."
Rails.logger.debug "URL #{url} could not be opened. Skipping."
end
end
Rails.logger.error "No file found at #{url} and various compression extensions."
return nil
end
# Try to load the Packages file for a certain component (e.g. "main")