123456789_123456789_123456789_123456789_123456789_

Class: Unicorn::TmpIO

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, File
Instance Chain:
self, File
Inherits: File
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

Instance Method Summary

  • #close!

    pretend we’re Tempfile for Rack::TempfileReaper

Constructor Details

.newTmpIO

creates and returns a new File object. The File is unlinked immediately, switched to binary mode, and userspace output buffering is disabled

[ GitHub ]

  
# File 'lib/unicorn/tmpio.rb', line 14

def self.new
  path = nil

  # workaround File#path being tainted:
  # https://bugs.ruby-lang.org/issues/14485
  fp = begin
    path = "#{Dir::tmpdir}/#{rand}"
    super(path, RDWR|CREAT|EXCL, 0600)
  rescue Errno::EEXIST
    retry
  end

  unlink(path)
  fp.binmode
  fp.sync = true
  fp
end

Instance Method Details

#close!

pretend we’re Tempfile for Rack::TempfileReaper

[ GitHub ]

  
# File 'lib/unicorn/tmpio.rb', line 33

alias close! close