fix(attestation): re-essaie une fois de telecharger le logo/signature au moment de generer l'attestation. sinon on peut se retrouver avec des dossier qui restent en status en construction alors qu'ils devraient etre automatiquement soit en instruction, soit accepte
This commit is contained in:
parent
24e610e247
commit
a73c3d8bdf
1 changed files with 16 additions and 0 deletions
|
@ -31,6 +31,22 @@ created_at = @attestation.fetch(:created_at)
|
|||
logo = @attestation[:logo]
|
||||
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|
|
||||
pdf.font_families.update('marianne' => { normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf') })
|
||||
pdf.font 'marianne'
|
||||
|
|
Loading…
Add table
Reference in a new issue