Module: Tus::Input::Unicorn

Included in:
Tus::Input
Defined in:
lib/tus/input/unicorn.rb

Overview

Extension for Unicorn to gracefully handle interrupted uploads.

Instance Method Summary collapse

Instance Method Details

#read(length = nil, outbuf = nil) ⇒ Object

Rescues Unicorn::ClientShutdown exception when reading, and instead of failing just returns blank data to signal end of input.



7
8
9
10
11
12
13
# File 'lib/tus/input/unicorn.rb', line 7

def read(length = nil, outbuf = nil)
  super
rescue => exception
  raise unless exception.class.name == "Unicorn::ClientShutdown"
  outbuf = outbuf.to_s.clear
  outbuf unless length
end