Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/files.rb')
-rw-r--r--lib/api/files.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/api/files.rb b/lib/api/files.rb
index 18638abd184..45e935d7ea2 100644
--- a/lib/api/files.rb
+++ b/lib/api/files.rb
@@ -30,7 +30,7 @@ module API
end
def assign_file_vars!
- authorize! :read_code, user_project
+ authorize_read_code!
@commit = user_project.commit(params[:ref])
not_found!('Commit') unless @commit
@@ -49,13 +49,21 @@ module API
end
def content_sha
- Rails.cache.fetch("blob_content_sha256:#{user_project.full_path}:#{@blob.id}") do
+ cache_client.fetch("blob_content_sha256:#{user_project.full_path}:#{@blob.id}") do
@blob.load_all_data!
Digest::SHA256.hexdigest(@blob.data)
end
end
+ def cache_client
+ Gitlab::Cache::Client.build_with_metadata(
+ cache_identifier: 'API::Files#content_sha',
+ feature_category: :source_code_management,
+ backing_resource: :gitaly
+ )
+ end
+
def fetch_blame_range(blame_params)
return if blame_params[:range].blank?