diff options
Diffstat (limited to 'lib/webrick')
-rw-r--r-- | lib/webrick/httpauth/htgroup.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/webrick/httpauth/htgroup.rb b/lib/webrick/httpauth/htgroup.rb index 399a62c37f..e06c441b18 100644 --- a/lib/webrick/httpauth/htgroup.rb +++ b/lib/webrick/httpauth/htgroup.rb @@ -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 |