demarches-normaliennes/app/models/concerns/blob_virus_scanner_concern.rb

30 lines
569 B
Ruby
Raw Normal View History

module BlobVirusScannerConcern
extend ActiveSupport::Concern
included do
2022-12-22 20:55:15 +01:00
self.ignored_columns = [:lock_version]
before_create :set_pending
end
def virus_scanner
ActiveStorage::VirusScanner.new(self)
end
def scan_for_virus_later
VirusScannerJob.perform_later(self)
end
def virus_scanner_error?
return true if virus_scanner.infected?
return true if virus_scanner.corrupt?
false
end
private
def set_pending
self.virus_scan_result = metadata[:virus_scan_result] || ActiveStorage::VirusScanner::PENDING
end
end