From 97e469fc3afb751618b8b9a7b364cb447aaf90dd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 19 Jul 2009 16:38:16 -0700 Subject: Remove core Tempfile dependency (1.9.2-preview1 compat) With the 1.9.2preview1 release (and presumably 1.9.1 p243), the Ruby core team has decided that bending over backwards to support crippled operating/file systems was necessary and that files must be closed before unlinking. Regardless, this is more efficient than using Tempfile because: 1) no delegation is necessary, this is a real File object 2) no mkdir is necessary for locking, we can trust O_EXCL to work properly without unnecessary FS activity 3) no finalizer is needed to unlink the file, we unlink it as soon as possible after creation. --- lib/unicorn/tee_input.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'lib/unicorn/tee_input.rb') diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 1bcbf1d..bbc496b 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -1,10 +1,8 @@ # Copyright (c) 2009 Eric Wong # You can redistribute it and/or modify it under the same terms as Ruby. -require 'tempfile' - # acts like tee(1) on an input input to provide a input-like stream -# while providing rewindable semantics through a Tempfile/StringIO +# while providing rewindable semantics through a File/StringIO # backing store. On the first pass, the input is only read on demand # so your Rack application can use input notification (upload progress # and like). This should fully conform to the Rack::InputWrapper @@ -16,10 +14,7 @@ module Unicorn class TeeInput def initialize(input, size, body) - @tmp = Tempfile.new(nil) - @tmp.unlink - @tmp.binmode - @tmp.sync = true + @tmp = Unicorn::Util.tmpio if body @tmp.write(body) -- cgit v1.2.3-24-ge0c7