Module: Sufia::GenericFile::VirusCheck
- Extended by:
- ActiveSupport::Concern
- Included in:
- Sufia::GenericFile
- Defined in:
- app/models/concerns/sufia/generic_file/virus_check.rb
Instance Method Summary collapse
-
#detect_viruses ⇒ Object
Default behavior is to raise a validation error and halt the save if a virus is found.
Instance Method Details
#detect_viruses ⇒ Object
Default behavior is to raise a validation error and halt the save if a virus is found
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/concerns/sufia/generic_file/virus_check.rb', line 11 def detect_viruses return unless content.changed? path = if content.content.respond_to?(:path) content.content.path else Tempfile.open('') do |t| t.binmode t.write(content.content) t.close t.path end end Sufia::GenericFile::Actor.virus_check(path) true rescue Sufia::VirusFoundError => virus logger.warn(virus.) errors.add(:base, virus.) false end |