lib/relaton/index/file_io.rb in relaton-index-0.2.10 vs lib/relaton/index/file_io.rb in relaton-index-0.2.11
- old
+ new
@@ -128,13 +128,14 @@
# @return [Array<Hash>] index
#
def fetch_and_save
resp = URI(url).open
zip = Zip::InputStream.new resp
- resp.close if resp.respond_to? :close
- resp.unlink if resp.is_a? Tempfile
+ resp.close! if resp.is_a? Tempfile
entry = zip.get_next_entry
- index = YAML.safe_load(entry.get_input_stream.read, permitted_classes: [Symbol])
+ yaml = entry.get_input_stream.read
+ entry.zipfile.close! if entry.zipfile.is_a? Tempfile
+ index = YAML.safe_load(yaml, permitted_classes: [Symbol])
save index
warn "[relaton-#{@dir}] Downloaded index from #{url}"
return index if check_format index
warn_remote_index_error "Wrong structure of"