summaryrefslogtreecommitdiff
path: root/lib/rubygems/package.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2022-10-06 15:43:48 +0900
committernagachika <nagachika@ruby-lang.org>2022-10-08 12:27:30 +0900
commitd77e6e653d32fa6287286cc68300abc0d1a299da (patch)
tree5eba1ad51312bb634e7660607e6cb699fad54607 /lib/rubygems/package.rb
parentd2f4cbf04215e536bcd06fde9cc7cec3b5566707 (diff)
Merge RubyGems-3.3.23 and Bundler-2.3.23
Diffstat (limited to 'lib/rubygems/package.rb')
-rw-r--r--lib/rubygems/package.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 084dc5d2d9..4672866985 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -444,10 +444,10 @@ EOM
directories << mkdir
end
- File.open destination, "wb" do |out|
- out.write entry.read
+ if entry.file?
+ File.open(destination, "wb") {|out| out.write entry.read }
FileUtils.chmod file_mode(entry.header.mode), destination
- end if entry.file?
+ end
verbose destination
end
@@ -467,7 +467,12 @@ EOM
end
def file_mode(mode) # :nodoc:
- ((mode & 0111).zero? ? data_mode : prog_mode) || mode
+ ((mode & 0111).zero? ? data_mode : prog_mode) ||
+ # If we're not using one of the default modes, then we're going to fall
+ # back to the mode from the tarball. In this case we need to mask it down
+ # to fit into 2^16 bits (the maximum value for a mode in CRuby since it
+ # gets put into an unsigned short).
+ (mode & ((1 << 16) - 1))
end
##