From 91115ea8479a66cafd493635e597ca0d1a592c9e Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 27 Nov 2018 14:02:29 +0100 Subject: [PATCH] [Fix sentry-26] if file does not exist, filename should be nil --- app/uploaders/procedure_logo_uploader.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/uploaders/procedure_logo_uploader.rb b/app/uploaders/procedure_logo_uploader.rb index 29e499c9d..c38970ac0 100644 --- a/app/uploaders/procedure_logo_uploader.rb +++ b/app/uploaders/procedure_logo_uploader.rb @@ -25,14 +25,16 @@ class ProcedureLogoUploader < BaseUploader end def filename - if original_filename.present? || model.logo_secure_token - if Flipflop.remote_storage? - filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}" - else - filename = "logo-#{secure_token}.#{file.extension.downcase}" + if file.present? + if original_filename.present? || model.logo_secure_token + if Flipflop.remote_storage? + filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}" + else + filename = "logo-#{secure_token}.#{file.extension.downcase}" + end end + filename end - filename end private