Skip to content

Commit

Permalink
fix appdata parsing
Browse files Browse the repository at this point in the history
I don't think the statement that open-uri decompresses automatically
is correct (and it seems not to work). The code does not reference
anything like that and probably the code is confusing Content-Type
with Content-Encoding. So, fix it to handle decompression correctly.

This makes fill_search_cache work again and screenshots appear in my
local copy that are not in software.opensuse.org current deploy.
  • Loading branch information
dmacvicar committed Oct 19, 2017
1 parent 4f52718 commit 47c80a9
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions app/models/appdata.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'open-uri'
require 'zlib'

class Appdata

Expand Down Expand Up @@ -37,15 +38,7 @@ def self.get_distribution(dist = 'factory', flavour = 'oss')
else
"http://download.opensuse.org/distribution/#{dist}/repo/#{flavour}/suse/setup/descr/appdata.xml.gz"
end
filename = File.join(Rails.root.join('tmp'), "appdata-" + dist + ".xml")
open(filename, 'wb') do |file|
# Gzip data will be automatically decompressed with open-uri
file << open(appdata_url).read
end
xmlfile = File.open(filename)
doc = Nokogiri::XML(xmlfile)
xmlfile.close
doc
Nokogiri::XML(Zlib::GzipReader.new(open(appdata_url)))
end

end

0 comments on commit 47c80a9

Please sign in to comment.