When a new PJ is uploaded enqueue a anti virus scan job
This commit is contained in:
parent
927cd3c6f4
commit
cd4615b10d
8 changed files with 105 additions and 0 deletions
20
app/jobs/anti_virus_job.rb
Normal file
20
app/jobs/anti_virus_job.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class AntiVirusJob < ApplicationJob
|
||||
include ActiveStorage::Downloading
|
||||
|
||||
attr_reader :blob
|
||||
|
||||
def perform(virus_scan)
|
||||
@blob = ActiveStorage::Blob.find_by(key: virus_scan.blob_key)
|
||||
|
||||
if @blob.present?
|
||||
download_blob_to_tempfile do |file|
|
||||
if ClamavService.safe_file?(file.path)
|
||||
status = "safe"
|
||||
else
|
||||
status = "infected"
|
||||
end
|
||||
virus_scan.update(scanned_at: Time.now, status: status)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue