From ada34d27ca1f615514d81e653dfd15fa48fe3dc3 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 23 Oct 2019 11:22:45 +1100 Subject: [PATCH] Avoid asking the cloud if an image exists https://github.com/openfoodfoundation/openfoodnetwork/issues/4392 Amazon's DNS is failing at the moment and some users can't access the admin panel because of this error. While `exists?` asks the storage server if the file is actually there, `file?` just checks if we have the file name stored in the database and the file should be there. It's much faster and less error prone. --- app/serializers/api/admin/enterprise_serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/serializers/api/admin/enterprise_serializer.rb b/app/serializers/api/admin/enterprise_serializer.rb index 1d1e45e4e8..bcb2fe39d7 100644 --- a/app/serializers/api/admin/enterprise_serializer.rb +++ b/app/serializers/api/admin/enterprise_serializer.rb @@ -62,7 +62,7 @@ class Api::Admin::EnterpriseSerializer < ActiveModel::Serializer # # medium: LOGO_MEDIUM_URL # # } def attachment_urls(attachment, versions) - return unless attachment.exists? + return unless attachment.file? versions.each_with_object({}) do |version, urls| urls[version] = attachment.url(version)