Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/rubygems/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def add_files(tar) # :nodoc:

tar.add_file_simple file, stat.mode, stat.size do |dst_io|
File.open file, "rb" do |src_io|
dst_io.write src_io.read 16_384 until src_io.eof?
copy_stream(src_io, dst_io)
end
end
end
Expand Down Expand Up @@ -452,7 +452,7 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
end

if entry.file?
File.open(destination, "wb") {|out| out.write entry.read }
File.open(destination, "wb") {|out| copy_stream(entry, out) }
FileUtils.chmod file_mode(entry.header.mode), destination
end

Expand Down Expand Up @@ -712,6 +712,16 @@ def verify_gz(entry) # :nodoc:
rescue Zlib::GzipFile::Error => e
raise Gem::Package::FormatError.new(e.message, entry.full_name)
end

if RUBY_ENGINE == "truffleruby"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a ruby engine version check as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a fixed version? I haven't heard anything. A ticket was mentioned but it had to do with the return value of copy_stream. I don't think this is cause by the return value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

truffleruby/truffleruby#3280 (comment) -- 23.1.2, to be released next month

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that makes sense. If it leaves our tar reader pos at the beginning, we can't possibly read the files right.

def copy_stream(src, dst) # :nodoc:
dst.write src.read
end
else
def copy_stream(src, dst) # :nodoc:
IO.copy_stream(src, dst)
end
end
end

require_relative "package/digest_io"
Expand Down