Skip to content

Commit 96c814d

Browse files
adamhooperothatbrian
authored andcommitted
Don't let Ruby auto-delete archives
1 parent 3043655 commit 96c814d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/git/lib.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,14 @@ def archive(sha, file = nil, opts = {})
699699
opts[:add_gzip] = true
700700
end
701701

702-
file ||= Tempfile.new('archive').path
703-
702+
if !file
703+
tempfile = Tempfile.new('archive')
704+
file = tempfile.path
705+
# delete it now, before we write to it, so that Ruby doesn't delete it
706+
# when it finalizes the Tempfile.
707+
tempfile.close!
708+
end
709+
704710
arr_opts = []
705711
arr_opts << "--format=#{opts[:format]}" if opts[:format]
706712
arr_opts << "--prefix=#{opts[:prefix]}" if opts[:prefix]

0 commit comments

Comments
 (0)