module Ratonvirus::Storage::Support::IoHandling
Private Instance Methods
io_path(io, extension) { |path| ... }
click to toggle source
This creates a local copy of the io contents for the scanning process. A local copy is needed for processing because the io object may be a file stream in the memory which may not have a path associated with it on the filesystem.
# File lib/ratonvirus/storage/support/io_handling.rb, line 15 def io_path(io, extension) tempfile = Tempfile.open( ["Ratonvirus", extension], tempdir ) # Important for the scanner to be able to access the file. prepare_for_scanner tempfile.path begin tempfile.binmode IO.copy_stream(io, tempfile) tempfile.flush tempfile.rewind yield tempfile.path ensure tempfile.close! end end
prepare_for_scanner(filepath)
click to toggle source
# File lib/ratonvirus/storage/support/io_handling.rb, line 39 def prepare_for_scanner(filepath) # Important for the scanner to be able to access the file. File.chmod(0o644, filepath) end
tempdir()
click to toggle source
# File lib/ratonvirus/storage/support/io_handling.rb, line 35 def tempdir Dir.tmpdir end