diff --git a/app/models/concerns/attachment_virus_scanner_concern.rb b/app/models/concerns/attachment_virus_scanner_concern.rb index 217d5e920..832d15a98 100644 --- a/app/models/concerns/attachment_virus_scanner_concern.rb +++ b/app/models/concerns/attachment_virus_scanner_concern.rb @@ -15,6 +15,13 @@ module AttachmentVirusScannerConcern private def scan_for_virus_later - blob&.scan_for_virus_later + return if blob.nil? + + # do not scan if the blob is already marked as safe + # usually because of metadata[:virus_scan_result] = ActiveStorage::VirusScanner::SAFE + # added on a blob built by the application itself + return if blob.virus_scan_result == ActiveStorage::VirusScanner::SAFE + + blob.scan_for_virus_later end end diff --git a/db/migrate/20240415192417_drop_virus_scan_table.rb b/db/migrate/20240415192417_drop_virus_scan_table.rb new file mode 100644 index 000000000..ba400126b --- /dev/null +++ b/db/migrate/20240415192417_drop_virus_scan_table.rb @@ -0,0 +1,5 @@ +class DropVirusScanTable < ActiveRecord::Migration[7.0] + def up + drop_table :virus_scans + end +end diff --git a/db/schema.rb b/db/schema.rb index 8fbba2a1a..743ba4e2a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_04_11_164502) do +ActiveRecord::Schema[7.0].define(version: 2024_04_15_192417) do # These are extensions that must be enabled in order to support this database enable_extension "pg_buffercache" enable_extension "pg_stat_statements" @@ -1148,16 +1148,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_11_164502) do t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true end - create_table "virus_scans", force: :cascade do |t| - t.string "blob_key" - t.bigint "champ_id" - t.datetime "created_at", precision: nil, null: false - t.datetime "scanned_at", precision: nil - t.string "status" - t.datetime "updated_at", precision: nil, null: false - t.index ["champ_id"], name: "index_virus_scans_on_champ_id" - end - create_table "without_continuation_mails", id: :serial, force: :cascade do |t| t.text "body" t.datetime "created_at", precision: nil, null: false diff --git a/spec/system/instructeurs/instruction_spec.rb b/spec/system/instructeurs/instruction_spec.rb index a826596dd..d6230e9b5 100644 --- a/spec/system/instructeurs/instruction_spec.rb +++ b/spec/system/instructeurs/instruction_spec.rb @@ -139,7 +139,7 @@ describe 'Instructing a dossier:', js: true do expect(page).to have_text("Export .csv d’un dossier « à suivre » demandé il y a moins d'une minute") expect(page).to have_text("En préparation") - assert_performed_jobs 2 do + assert_performed_jobs 1 do perform_enqueued_jobs(only: ExportJob) end