diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-07-05 10:51:11 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-07-05 10:51:11 -0400 |
commit | c7b68b6e66a487b8b12556fe10dd1dde78581eca (patch) | |
tree | 78cf2dde88e29674d8fa2f78293fb1b20ea887c8 /app/models | |
parent | 38533a2f4252921bbfde126c887510481aeaa01e (diff) | |
download | gitlab-ce-c7b68b6e66a487b8b12556fe10dd1dde78581eca.tar.gz |
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
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/group.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index a8be7004ee8..37631b99701 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -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 diff --git a/app/models/project.rb b/app/models/project.rb index ae96f00a705..e5fae15cb19 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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) diff --git a/app/models/user.rb b/app/models/user.rb index 5036a3e300c..695a47ba6eb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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) |