Skip to content

Commit e292914

Browse files
committed
Revert "Fix yield_chunks method and improve error handling"
This reverts commit a5b24e7.
1 parent 018d842 commit e292914

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

lib/remote_input/downloader.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,11 @@ def download(output_path, &block)
213213
end
214214
end
215215

216-
private def yield_chunks(path, &block)
217-
return unless block_given?
218-
219-
path.open("rb") do |input|
216+
private def yield_chunks(path)
217+
path.open("rb") do |output|
220218
chunk_size = 1024 * 1024
221-
while chunk = input.read(chunk_size)
219+
chunk = +""
220+
while output.read(chunk_size, chunk)
222221
yield(chunk)
223222
end
224223
end

test/test-downloader.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,6 @@ def teardown
7777
downloader.download(output_path)
7878
assert_equal("cached content", output_path.read)
7979
end
80-
81-
test("yield chunks when using cache") do
82-
output_path = @tmp_dir + "cached_file"
83-
content = "chunk1chunk2chunk3"
84-
output_path.write(content)
85-
86-
downloader = RemoteInput::Downloader.new("https://example.com/file")
87-
88-
chunks = []
89-
downloader.download(output_path) do |chunk|
90-
chunks << chunk
91-
end
92-
93-
assert_equal(content, chunks.join)
94-
end
9580
end
9681

9782
sub_test_case("fallback URLs") do

0 commit comments

Comments
 (0)