diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-12-08 18:52:20 +1100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-12-22 11:44:43 +0100 |
commit | 1b6c663cb29ed42433a87a64926d4267c25d3177 (patch) | |
tree | 66907dcced759e16195863c8a52c18567759f842 /lib/banzai | |
parent | 6d9c1d3efce00da95832feaaf36227bcbffecadf (diff) | |
download | gitlab-ce-1b6c663cb29ed42433a87a64926d4267c25d3177.tar.gz |
Fix lookup of project by unknown ref when caching is enabled
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/abstract_reference_filter.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb index fd74eeaebe7..966db96f951 100644 --- a/lib/banzai/filter/abstract_reference_filter.rb +++ b/lib/banzai/filter/abstract_reference_filter.rb @@ -254,15 +254,26 @@ module Banzai # Returns projects for the given paths. def find_projects_for_paths(paths) if RequestStore.active? - to_query = paths - project_refs_cache.keys + cache = project_refs_cache + to_query = paths - cache.keys unless to_query.empty? - projects_relation_for_paths(to_query).each do |project| - get_or_set_cache(project_refs_cache, project.path_with_namespace) { project } + projects = projects_relation_for_paths(to_query) + + found = [] + projects.each do |project| + ref = project.path_with_namespace + get_or_set_cache(cache, project.path_with_namespace) { project } + found << ref + end + + not_found = to_query - found + not_found.each do |ref| + get_or_set_cache(cache, ref) { nil } end end - project_refs_cache.slice(*paths).values + cache.slice(*paths).values.compact else projects_relation_for_paths(paths) end |