Skip to content

Commit 8072c8b

Browse files
Merge pull request #8965 from tenderlove/file-chmod
Use File#chmod rather than FileUtils.chmod
2 parents 8f1354e + 60c14bb commit 8072c8b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/rubygems/package.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,14 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
451451
end
452452

453453
if entry.file?
454-
File.open(destination, "wb") {|out| copy_stream(entry, out) }
455-
FileUtils.chmod file_mode(entry.header.mode) & ~File.umask, destination
454+
File.open(destination, "wb") do |out|
455+
copy_stream(entry, out)
456+
# Flush needs to happen before chmod because there could be data
457+
# in the IO buffer that needs to be written, and that could be
458+
# written after the chmod (on close) which would mess up the perms
459+
out.flush
460+
out.chmod file_mode(entry.header.mode) & ~File.umask
461+
end
456462
end
457463

458464
verbose destination

0 commit comments

Comments
 (0)