summaryrefslogtreecommitdiff
path: root/lib/tempfile.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-20 00:35:30 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-20 00:35:30 +0000
commitc81863c321798391409f8beb2c1660309964efda (patch)
tree47d5ff9db01a9174199329861b032b8ae19ae90b /lib/tempfile.rb
parent91e5ba1cb865a2385d3e1cbfacd824496898e098 (diff)
* lib/tempfile.rb (Tempfile#unlink): close first for Windows. a
patch from Florian Frank. [ruby-core:23505] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tempfile.rb')
-rw-r--r--lib/tempfile.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index e3934b5..46803b2 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -136,7 +136,10 @@ class Tempfile < DelegateClass(File)
def unlink
# keep this order for thread safeness
begin
- File.unlink(@tmpname) if File.exist?(@tmpname)
+ if File.exist?(@tmpname)
+ closed? or close
+ File.unlink(@tmpname)
+ end
@@cleanlist.delete(@tmpname)
@data = @tmpname = nil
ObjectSpace.undefine_finalizer(self)