Class: Unicorn::TmpIO
- Inherits:
-
File
- Object
- File
- Unicorn::TmpIO
- Defined in:
- lib/unicorn/tmpio.rb
Overview
some versions of Ruby had a broken Tempfile which didn’t work well with unlinked files. This one is much shorter, easier to understand, and slightly faster.
Class Method Summary collapse
-
.new ⇒ Object
creates and returns a new File object.
Instance Method Summary collapse
-
#size ⇒ Object
for easier env compatibility with Rack <= 1.1.
Class Method Details
.new ⇒ Object
creates and returns a new File object. The File is unlinked immediately, switched to binary mode, and userspace output buffering is disabled
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/unicorn/tmpio.rb', line 13 def self.new fp = begin super("#{Dir::tmpdir}/#{rand}", RDWR|CREAT|EXCL, 0600) rescue Errno::EEXIST retry end unlink(fp.path) fp.binmode fp.sync = true fp end |
Instance Method Details
#size ⇒ Object
for easier env compatibility with Rack <= 1.1
26 27 28 |
# File 'lib/unicorn/tmpio.rb', line 26 def size stat.size end |