2019-11-20 16:03:40 +01:00
|
|
|
module BlobVirusScannerConcern
|
2019-05-16 18:59:34 +02:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
before_create :set_pending
|
|
|
|
end
|
|
|
|
|
|
|
|
def virus_scanner
|
|
|
|
ActiveStorage::VirusScanner.new(self)
|
|
|
|
end
|
|
|
|
|
2021-03-11 14:42:57 +01:00
|
|
|
def scan_for_virus_later
|
|
|
|
VirusScannerJob.perform_later(self)
|
|
|
|
end
|
|
|
|
|
2022-11-09 12:33:20 +01:00
|
|
|
def virus_scanner_error?
|
|
|
|
return true if virus_scanner.infected?
|
|
|
|
return true if virus_scanner.corrupt?
|
|
|
|
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2019-05-16 18:59:34 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_pending
|
2021-03-11 14:42:57 +01:00
|
|
|
metadata[:virus_scan_result] ||= ActiveStorage::VirusScanner::PENDING
|
2019-05-16 18:59:34 +02:00
|
|
|
end
|
|
|
|
end
|