Sha256: 35dda84d6410f3b191fcedbb0a1567f6312fbc1bbd0d4f8dff033aa7c2a35ba9
Contents?: true
Size: 897 Bytes
Versions: 4
Compression:
Stored size: 897 Bytes
Contents
# -*- encoding: binary -*- # frozen_string_literal: true # :stopdoc: require 'tmpdir' module Pitchfork # 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 TmpIO < File # creates and returns a new File object. The File is unlinked # immediately, switched to binary mode, and userspace output # buffering is disabled 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 # pretend we're Tempfile for Rack::TempfileReaper alias close! close end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pitchfork-0.16.0 | lib/pitchfork/tmpio.rb |
pitchfork-0.15.0 | lib/pitchfork/tmpio.rb |
pitchfork-0.14.0 | lib/pitchfork/tmpio.rb |
pitchfork-0.13.0 | lib/pitchfork/tmpio.rb |