class Archive::Tar::StreamReader
Public Class Methods
new(stream, options = {})
click to toggle source
Calls superclass method
Archive::Tar::Reader::new
# File lib/archive/tar/stream_reader.rb, line 26 def initialize(stream, options = {}) options = { block_size: 2 ** 19, reload_time: 32 }.merge(options) stream = IO.new(stream) if io.is_a? Integer if options[:compression] == :auto raise "Automatic compression is not available for streams" end tmp_file = File.new("/tmp/" + rand(500000).to_s(16) + ".tar", "w+b") Thread.new do i = 0 until stream.eof? read = stream.read(options[:block_size]) tmp_file.write(read) self.build_index if i % options[:reload_time] == 0 i += 1 end self.build_index end super(tmp_file, options) end