From 2c3562e82953a5fc5aa7736d700741a74a82c5c0 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 10 Oct 2023 10:09:20 +0200 Subject: [PATCH 1/2] bug(export.identify): identify pourrait etre la cause des exports remis a 0 [mauvais identification due au type de contenu] --- spec/jobs/export_job_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spec/jobs/export_job_spec.rb diff --git a/spec/jobs/export_job_spec.rb b/spec/jobs/export_job_spec.rb new file mode 100644 index 00000000000..a6e26c6a753 --- /dev/null +++ b/spec/jobs/export_job_spec.rb @@ -0,0 +1,29 @@ +describe ExportJob do + let(:procedure) { create(:procedure, instructeurs: [instructeur]) } + let(:instructeur) { create(:instructeur) } + let(:time_span_type) { :everything } + let(:status) { :tous } + let(:key) { '123' } + let(:export) do + create(:export, format:, + time_span_type:, + key:, + instructeur:, + groupe_instructeurs: procedure.groupe_instructeurs) + end + + subject do + ExportJob.perform_now(export) + end + before do + allow_any_instance_of(ArchiveUploader).to receive(:syscall_to_custom_uploader).and_return(true) + end + + context 'zip' do + let(:format) { :zip } + + it 'does not try to identify file' do + expect { subject }.not_to raise_error(ActiveStorage::FileNotFoundError) + end + end +end From f4430cebb0e84fe129b3e74a7e71ef1270fc708f Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 10 Oct 2023 10:20:47 +0200 Subject: [PATCH 2/2] =?UTF-8?q?bug(export.identify):=20la=20cl=C3=A9=20pou?= =?UTF-8?q?r=20declarer=20que=20le=20fichier=20a=20deja=20ete=20identifie?= =?UTF-8?q?=20[content=5Ftype]=20est=20identified,=20pas=20identify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/archive_uploader.rb | 5 ++--- app/services/procedure_export_service.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/services/archive_uploader.rb b/app/services/archive_uploader.rb index 56e306dd1bf..ee4563c296c 100644 --- a/app/services/archive_uploader.rb +++ b/app/services/archive_uploader.rb @@ -38,8 +38,7 @@ def active_storage_service_local? end def upload_with_active_storage - params = blob_default_params(filepath).merge(io: File.open(filepath), - identify: false) + params = blob_default_params(filepath).merge(io: File.open(filepath)) blob = ActiveStorage::Blob.create_and_upload!(**params) return blob end @@ -64,7 +63,7 @@ def blob_default_params(filepath) key: namespaced_object_key, filename: filename, content_type: 'application/zip', - metadata: { analyzed: true, virus_scan_result: ActiveStorage::VirusScanner::SAFE } + metadata: { analyzed: true, identified: true, virus_scan_result: ActiveStorage::VirusScanner::SAFE } } end diff --git a/app/services/procedure_export_service.rb b/app/services/procedure_export_service.rb index 04a8c44fb5d..4769f2a8dbb 100644 --- a/app/services/procedure_export_service.rb +++ b/app/services/procedure_export_service.rb @@ -56,7 +56,7 @@ def create_blob(io, format) content_type: content_type(format), identify: false, # We generate the exports ourselves, so they are safe - metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE } + metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE, identified: true } ) end