Dumb-down avatar presence check in avatar_url methods

`avatar.present?` goes through CarrierWave, and checks that the file
exists on disk and checks its filesize. Because we're hitting the disk,
this adds extra overhead to something where the worst-case scenario is
rendering a broken image.

Instead, we now just check that the _database attribute_ is present,
which is good enough for our purposes.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/19273
This commit is contained in:
Robert Speicher 2016-07-05 10:51:11 -04:00
parent 38533a2f42
commit c7b68b6e66
3 changed files with 3 additions and 3 deletions

View file

@ -90,7 +90,7 @@ class Group < Namespace
end
def avatar_url(size = nil)
if avatar.present?
if self[:avatar].present?
[gitlab_config.url, avatar.url].join
end
end

View file

@ -701,7 +701,7 @@ class Project < ActiveRecord::Base
end
def avatar_url
if avatar.present?
if self[:avatar].present?
[gitlab_config.url, avatar.url].join
elsif avatar_in_git
Gitlab::Routing.url_helpers.namespace_project_avatar_url(namespace, self)

View file

@ -653,7 +653,7 @@ class User < ActiveRecord::Base
end
def avatar_url(size = nil, scale = 2)
if avatar.present?
if self[:avatar].present?
[gitlab_config.url, avatar.url].join
else
GravatarService.new.execute(email, size, scale)