From: Tanaka Akira Date: 2018-08-14T17:30:08+09:00 Subject: [ruby-core:88477] Re: [ruby-cvs:71330] normal:r64238 (trunk): test/lib/leakchecker.rb (find_tempfiles): don't warn for missing files 2018���8���9���(���) 11:14 : > > normal 2018-08-09 11:14:27 +0900 (Thu, 09 Aug 2018) > > New Revision: 64238 > > https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64238 > > Log: > test/lib/leakchecker.rb (find_tempfiles): don't warn for missing files > > Quiet a false-positive warning from TestHtgroup#test_htgroup I think it is not a good idea because Tempfile still invokes unlink system call on the missing file. It is better to avoid such file operation in /tmp. For example, following patch changes Tempfile.new to Tempfile.create to avoid unnecessary unlink. --- lib/webrick/httpauth/htgroup.rb 2018-08-13 02:20:27.168767081 +0900 +++ lib/webrick/httpauth/htgroup.rb+ 2018-08-13 02:20:24.548817671 +0900 @@ -63,16 +63,20 @@ def flush(output=nil) output ||= @path - tmp = Tempfile.new("htgroup", File::dirname(output)) + tmp = Tempfile.create("htgroup", File::dirname(output)) begin @group.keys.sort.each{|group| tmp.puts(format("%s: %s", group, self.members(group).join(" "))) } + ensure tmp.close - File::rename(tmp.path, output) - rescue - tmp.close(true) + if $! + File.unlink(tmp.path) + else + File.rename(tmp.path, output) + end end + nil end ## Note that this patch changes the return value of this method from 0 to nil. -- Tanaka Akira Unsubscribe: