Merge pull request #8478 from mfo/hs/2130856854/2011688
amelioration(modele_attestation): re-tente a génération de l'attestation dans le cas ou notre objectstorage est en bagotage
This commit is contained in:
commit
dcf2b92ef5
1 changed files with 16 additions and 0 deletions
|
@ -31,6 +31,22 @@ created_at = @attestation.fetch(:created_at)
|
||||||
logo = @attestation[:logo]
|
logo = @attestation[:logo]
|
||||||
signature = @attestation[:signature]
|
signature = @attestation[:signature]
|
||||||
|
|
||||||
|
def download_file_and_retry(file_or_attached_one, max_attempts = 3)
|
||||||
|
if file_or_attached_one.is_a?(ActiveStorage::Attached::One)
|
||||||
|
file_or_attached_one.download
|
||||||
|
else
|
||||||
|
file_or_attached_one.rewind && file_or_attached_one.read
|
||||||
|
end
|
||||||
|
rescue Fog::OpenStack::Storage::NotFound => e
|
||||||
|
if max_attempts > 0
|
||||||
|
max_attempts = max_attempts - 1
|
||||||
|
sleep 1
|
||||||
|
retry
|
||||||
|
else
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], page_size: page_size) do |pdf|
|
prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], page_size: page_size) do |pdf|
|
||||||
pdf.font_families.update('marianne' => { normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf') })
|
pdf.font_families.update('marianne' => { normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf') })
|
||||||
pdf.font 'marianne'
|
pdf.font 'marianne'
|
||||||
|
|
Loading…
Add table
Reference in a new issue