summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-03-08 10:33:59 +0000
committerIan Baum <ibaum@gitlab.com>2018-03-15 15:03:26 -0500
commit785169c70922be8d1f280b47374a509fbd40e58a (patch)
treebf86cadbbc6d5fb48ccbbeeb79f661a84f9542dc /app
parent7e01ed86152af96901231a4b495f19639fb63df4 (diff)
downloadgitlab-ce-785169c70922be8d1f280b47374a509fbd40e58a.tar.gz
Merge branch 'sh-remove-double-caching-repo-empty' into 'master'10-5-stable-patch-5
Remove double caching of Repository#empty? Closes #43882 See merge request gitlab-org/gitlab-ce!17588
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 4f754b11da4..da0a4c1a273 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -35,7 +35,7 @@ class Repository
CACHED_METHODS = %i(size commit_count rendered_readme contribution_guide
changelog license_blob license_key gitignore koding_yml
gitlab_ci_yml branch_names tag_names branch_count
- tag_count avatar exists? empty? root_ref has_visible_content?
+ tag_count avatar exists? root_ref has_visible_content?
issue_template_names merge_request_template_names).freeze
# Methods that use cache_method but only memoize the value
@@ -359,7 +359,7 @@ class Repository
def expire_emptiness_caches
return unless empty?
- expire_method_caches(%i(empty? has_visible_content?))
+ expire_method_caches(%i(has_visible_content?))
end
def lookup_cache
@@ -509,12 +509,14 @@ class Repository
end
cache_method :exists?
+ # We don't need to cache the output of this method because both exists? and
+ # has_visible_content? are already memoized and cached. There's no guarantee
+ # that the values are expired and loaded atomically.
def empty?
return true unless exists?
!has_visible_content?
end
- cache_method :empty?
# The size of this repository in megabytes.
def size