зеркало из https://github.com/github/ruby.git
webrick/httpauth/htgroup.rb (flush): avoid unnecessary unlink
Based on patch by akr [ruby-core:88477], use Tempfile.create to avoid unnecessary unlink call. Unlike akr's original patch, this does not change the return value of flush. Thanks-to: Tanaka Akira <akr@fsij.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7d664ecc49
Коммит
ab7e34e4db
|
@ -63,15 +63,18 @@ module WEBrick
|
|||
|
||||
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
|
||||
return File.rename(tmp.path, output)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче