Skip to content

Commit

Permalink
unlink temp file #4
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2net committed Jan 10, 2024
1 parent 7da8d51 commit dada4e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/relaton/index/file_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def warn_local_index_error(reason)
def fetch_and_save
resp = URI(url).open
zip = Zip::InputStream.new resp
resp.close
resp.unlink
entry = zip.get_next_entry
index = YAML.safe_load(entry.get_input_stream.read, permitted_classes: [Symbol])
save index
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton/index/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Relaton
module Index
VERSION = "0.2.8"
VERSION = "0.2.9"
end
end
7 changes: 5 additions & 2 deletions spec/relaton/file_io_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@
before do
subject.instance_variable_set(:@url, "url")
uri = double("uri")
expect(uri).to receive(:open).and_return :resp
resp = double("resp")
expect(resp).to receive(:close)
expect(resp).to receive(:unlink)
expect(uri).to receive(:open).and_return resp
expect(URI).to receive(:parse).with("url").and_return uri
entry = double("entry")
yaml = "---\n- :id: 1\n :file: data/1.yaml\n"
expect(entry).to receive_message_chain(:get_input_stream, :read).and_return yaml
zip = double("zip")
expect(zip).to receive(:get_next_entry).and_return entry
expect(Zip::InputStream).to receive(:new).with(:resp).and_return zip
expect(Zip::InputStream).to receive(:new).with(resp).and_return zip
end

it "success" do
Expand Down

0 comments on commit dada4e4

Please sign in to comment.