Merge pull request #9582 from demarches-simplifiees/US/fix-export-job
correctif(tech.export): il arrive que des exports soient mal identifié (le content-type), ce qui par la suite renvoie des exports vide (0kb)
This commit is contained in:
commit
ade95f5f5f
3 changed files with 32 additions and 4 deletions
|
@ -38,8 +38,7 @@ class ArchiveUploader
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_with_active_storage
|
def upload_with_active_storage
|
||||||
params = blob_default_params(filepath).merge(io: File.open(filepath),
|
params = blob_default_params(filepath).merge(io: File.open(filepath))
|
||||||
identify: false)
|
|
||||||
blob = ActiveStorage::Blob.create_and_upload!(**params)
|
blob = ActiveStorage::Blob.create_and_upload!(**params)
|
||||||
return blob
|
return blob
|
||||||
end
|
end
|
||||||
|
@ -64,7 +63,7 @@ class ArchiveUploader
|
||||||
key: namespaced_object_key,
|
key: namespaced_object_key,
|
||||||
filename: filename,
|
filename: filename,
|
||||||
content_type: 'application/zip',
|
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
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class ProcedureExportService
|
||||||
content_type: content_type(format),
|
content_type: content_type(format),
|
||||||
identify: false,
|
identify: false,
|
||||||
# We generate the exports ourselves, so they are safe
|
# 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
|
end
|
||||||
|
|
||||||
|
|
29
spec/jobs/export_job_spec.rb
Normal file
29
spec/jobs/export_job_spec.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue