2019-11-20 16:03:40 +01:00
|
|
|
module BlobVirusScannerConcern
|
2019-05-16 18:59:34 +02:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2023-04-19 11:23:47 +02:00
|
|
|
self.ignored_columns += [:lock_version]
|
2019-05-16 18:59:34 +02:00
|
|
|
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
|
2022-12-22 18:20:58 +01:00
|
|
|
self.virus_scan_result = metadata[:virus_scan_result] || ActiveStorage::VirusScanner::PENDING
|
2019-05-16 18:59:34 +02:00
|
|
|
end
|
|
|
|
end
|