* lib/webrick/httpauth/htpasswd.rb: Use Tempfile.create to avoid
unintentional unlink() by the finalizer. lib/webrick/httpauth/htdigest.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5388fb64d9
commit
5fb8bb16e6
@ -1,3 +1,9 @@
|
|||||||
|
Sat Apr 20 23:38:14 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/webrick/httpauth/htpasswd.rb: Use Tempfile.create to avoid
|
||||||
|
unintentional unlink() by the finalizer.
|
||||||
|
lib/webrick/httpauth/htdigest.rb: Ditto.
|
||||||
|
|
||||||
Sat Apr 20 22:47:48 2013 Tanaka Akira <akr@fsij.org>
|
Sat Apr 20 22:47:48 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* lib/tempfile.rb (Tempfile.create): New method.
|
* lib/tempfile.rb (Tempfile.create): New method.
|
||||||
|
@ -70,13 +70,16 @@ module WEBrick
|
|||||||
|
|
||||||
def flush(output=nil)
|
def flush(output=nil)
|
||||||
output ||= @path
|
output ||= @path
|
||||||
tmp = Tempfile.new("htpasswd", File::dirname(output))
|
tmp = Tempfile.create("htpasswd", File::dirname(output))
|
||||||
|
renamed = false
|
||||||
begin
|
begin
|
||||||
each{|item| tmp.puts(item.join(":")) }
|
each{|item| tmp.puts(item.join(":")) }
|
||||||
tmp.close
|
tmp.close
|
||||||
File::rename(tmp.path, output)
|
File::rename(tmp.path, output)
|
||||||
rescue
|
renamed = true
|
||||||
tmp.close(true)
|
ensure
|
||||||
|
tmp.close if !tmp.closed?
|
||||||
|
File.unlink(tmp.path) if !renamed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,13 +75,16 @@ module WEBrick
|
|||||||
|
|
||||||
def flush(output=nil)
|
def flush(output=nil)
|
||||||
output ||= @path
|
output ||= @path
|
||||||
tmp = Tempfile.new("htpasswd", File::dirname(output))
|
tmp = Tempfile.create("htpasswd", File::dirname(output))
|
||||||
|
renamed = false
|
||||||
begin
|
begin
|
||||||
each{|item| tmp.puts(item.join(":")) }
|
each{|item| tmp.puts(item.join(":")) }
|
||||||
tmp.close
|
tmp.close
|
||||||
File::rename(tmp.path, output)
|
File::rename(tmp.path, output)
|
||||||
rescue
|
renamed = true
|
||||||
tmp.close(true)
|
ensure
|
||||||
|
tmp.close if !tmp.closed?
|
||||||
|
File.unlink(tmp.path) if !renamed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user