lib/ddr/actions/virus_check.rb in ddr-models-2.6.2 vs lib/ddr/actions/virus_check.rb in ddr-models-2.7.0.rc1

- old
+ new

@@ -1,27 +1,21 @@ -require "ostruct" -require "shellwords" - module Ddr::Actions class VirusCheck # @return [Hash] result data # @raises [Ddr::Antivirus::VirusFoundError] def self.call(file_path) - unless File.exist?(file_path) - raise Error, "File not found: #{file_path}" + Hash.new.tap do |result| + begin + scan_result = Ddr::Antivirus.scan(file_path) + rescue Ddr::Antivirus::ScannerError => e + result[:exception] = [e.class.name, e.to_s] + scan_result = e.result + end + result[:event_date_time] = scan_result.scanned_at + result[:software] = scan_result.version + result[:detail] = scan_result.output end - result = {} - begin - scan_result = Ddr::Antivirus.scan(file_path) - rescue Ddr::Antivirus::ScannerError => e - result[:exception] = [e.class.name, e.to_s] - scan_result = e.result - end - result[:event_date_time] = scan_result.scanned_at - result[:software] = scan_result.version - result[:detail] = scan_result.output - result end end end