summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/package.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index c855423ed7..99be691ec7 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -451,8 +451,14 @@ EOM
end
if entry.file?
- File.open(destination, "wb") {|out| copy_stream(entry, out) }
- FileUtils.chmod file_mode(entry.header.mode) & ~File.umask, destination
+ File.open(destination, "wb") do |out|
+ copy_stream(entry, out)
+ # Flush needs to happen before chmod because there could be data
+ # in the IO buffer that needs to be written, and that could be
+ # written after the chmod (on close) which would mess up the perms
+ out.flush
+ out.chmod file_mode(entry.header.mode) & ~File.umask
+ end
end
verbose destination