From 82c89fb56fb3878c6b78dcc4fc4929c0b13aa22f Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 26 Aug 2020 16:11:01 +0200 Subject: [PATCH] config: remove comment about ActiveStorage integration with VirusScanner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the comment states, it would be nice to load the Virus Scanner on the Attachment (rather than the blob). However, in order not to clobber the blob metadata, we want to run the VirusScanner once the blob analyzer did run. And the most direct way to detect that the blob analyzer did run is to add an `on_update_commit` hook on the blob, as this hook will be trigerred when saving changes to the metadata. This is what the current solution uses. So the current solution is almost optimal, and has a low chance of accidentally clobbering the blob metadata – as the virus scanner is only started when the analysis phase is finished. --- config/initializers/active_storage.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/initializers/active_storage.rb b/config/initializers/active_storage.rb index 5cc61f6c1..6be3549bc 100644 --- a/config/initializers/active_storage.rb +++ b/config/initializers/active_storage.rb @@ -1,11 +1,5 @@ Rails.application.config.active_storage.service_urls_expire_in = 1.hour -# In Rails 5.2, we have to hook at `on_load` on the blob themeselves, which is -# not ideal. -# -# Rails 6 adds support for `.on_load(:active_storage_attachment)`, which is -# cleaner (as it allows to enqueue the virus scan on attachment creation, rather -# than on blob creation). ActiveSupport.on_load(:active_storage_blob) do include BlobSignedIdConcern include BlobVirusScannerConcern