Skip to content

Commit ba06c35

Browse files
authored
Merge pull request #8966 from tenderlove/copy-stream
Pass a file size to `IO.copy_stream`
2 parents 8072c8b + 8927533 commit ba06c35

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/rubygems/package.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def add_files(tar) # :nodoc:
267267

268268
tar.add_file_simple file, stat.mode, stat.size do |dst_io|
269269
File.open file, "rb" do |src_io|
270-
copy_stream(src_io, dst_io)
270+
copy_stream(src_io, dst_io, stat.size)
271271
end
272272
end
273273
end
@@ -452,7 +452,7 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
452452

453453
if entry.file?
454454
File.open(destination, "wb") do |out|
455-
copy_stream(entry, out)
455+
copy_stream(entry, out, entry.size)
456456
# Flush needs to happen before chmod because there could be data
457457
# in the IO buffer that needs to be written, and that could be
458458
# written after the chmod (on close) which would mess up the perms
@@ -721,12 +721,12 @@ def verify_gz(entry) # :nodoc:
721721
end
722722

723723
if RUBY_ENGINE == "truffleruby"
724-
def copy_stream(src, dst) # :nodoc:
725-
dst.write src.read
724+
def copy_stream(src, dst, size) # :nodoc:
725+
dst.write src.read(size)
726726
end
727727
else
728-
def copy_stream(src, dst) # :nodoc:
729-
IO.copy_stream(src, dst)
728+
def copy_stream(src, dst, size) # :nodoc:
729+
IO.copy_stream(src, dst, size)
730730
end
731731
end
732732

0 commit comments

Comments
 (0)