summaryrefslogtreecommitdiff
path: root/lib/gitlab/project_search_results.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/project_search_results.rb')
-rw-r--r--lib/gitlab/project_search_results.rb22
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb
index db325c00705..561aa9e162c 100644
--- a/lib/gitlab/project_search_results.rb
+++ b/lib/gitlab/project_search_results.rb
@@ -62,7 +62,7 @@ module Gitlab
data << line.sub(ref, '').sub(filename, '').sub(/^:-\d+-/, '').sub(/^::\d+:/, '')
end
- OpenStruct.new(
+ FoundBlob.new(
filename: filename,
basename: basename,
ref: ref,
@@ -82,26 +82,14 @@ module Gitlab
private
def blobs
- @blobs ||= begin
- blobs = project.repository.search_files_by_content(query, repository_ref).first(100)
- found_file_names = Set.new
-
- results = blobs.map do |blob|
- blob = self.class.parse_search_result(blob)
- found_file_names << blob.filename
-
- [blob.filename, blob]
- end
-
- project.repository.search_files_by_name(query, repository_ref).first(100).each do |filename|
- results << [filename, nil] unless found_file_names.include?(filename)
- end
+ return [] unless Ability.allowed?(@current_user, :download_code, @project)
- results.sort_by(&:first)
- end
+ @blobs ||= Gitlab::FileFinder.new(project, repository_ref).find(query)
end
def wiki_blobs
+ return [] unless Ability.allowed?(@current_user, :read_wiki, @project)
+
@wiki_blobs ||= begin
if project.wiki_enabled? && query.present?
project_wiki = ProjectWiki.new(project)