summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-03-17 16:53:05 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2016-03-17 17:02:24 +0100
commita18bf1e24ce7cf987912c8496d92d355293863dd (patch)
tree96caa072ca8b1c0b71120e8dc7b42526a117fc3d /app/models/project.rb
parentf728e4b519bc153534dc9632aa37932e2ac24801 (diff)
downloadgitlab-ce-caching-project-avatars.tar.gz
Cache project avatars stored in Gitcaching-project-avatars
The avatar logic has been moved from Project to Repository as this makes caching easier. The logic itself in turn has been changed so that the logo file names are cached in Redis. This cache is flushed upon pushing a commit but _only_ if: 1. The commit was pushed to the default branch 2. The commit actually changes any of the logo files If no branch or commit is given the cache is flushed anyway, this ensures that calling Repository#expire_cache without any arguments still flushes the avatar cache (e.g. this is used when removing a project). Fixes gitlab-org/gitlab-ce#14363
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb5
1 files changed, 1 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index ab4913e99a8..412c6c6732d 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -571,10 +571,7 @@ class Project < ActiveRecord::Base
end
def avatar_in_git
- @avatar_file ||= 'logo.png' if repository.blob_at_branch('master', 'logo.png')
- @avatar_file ||= 'logo.jpg' if repository.blob_at_branch('master', 'logo.jpg')
- @avatar_file ||= 'logo.gif' if repository.blob_at_branch('master', 'logo.gif')
- @avatar_file
+ repository.avatar
end
def avatar_url