From f511dfbd56bc6f9b0eb8fec8bfa16cf3a0109033 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Fri, 24 Apr 2015 16:58:08 +0200 Subject: [PATCH] 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. --- lib/deb_importer.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/deb_importer.rb b/lib/deb_importer.rb index 914da70..b85dba4 100644 --- a/lib/deb_importer.rb +++ b/lib/deb_importer.rb @@ -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")