Fix exception while writing utf8 to cache
This commit is contained in:
parent
517ff4bd76
commit
18ba6bea34
|
@ -9,6 +9,8 @@ module MusicBrainz
|
|||
end
|
||||
|
||||
def load(resource, query, params)
|
||||
raise Exception.new("You need to run MusicBrainz.configure before querying") if MusicBrainz.config.nil?
|
||||
|
||||
response = contents_of(build_url(resource, query))
|
||||
xml = Nokogiri::XML.parse(response).remove_namespaces!.xpath('/metadata')
|
||||
data = params[:binding].parse(xml)
|
||||
|
|
|
@ -18,12 +18,12 @@ module MusicBrainz
|
|||
response = nil
|
||||
|
||||
if File.exist?(file_path)
|
||||
response = File.open(file_path).gets
|
||||
response = File.open(file_path, 'rb').gets
|
||||
else
|
||||
response = super
|
||||
unless response.nil? or response.empty?
|
||||
FileUtils.mkdir_p file_path.split('/')[0..-2].join('/')
|
||||
File.open(file_path, 'w') do |f|
|
||||
File.open(file_path, 'wb') do |f|
|
||||
f.puts response
|
||||
f.chmod 0755
|
||||
f.close
|
||||
|
|
Loading…
Reference in New Issue