diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-06 00:07:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-06 00:07:40 +0300 |
commit | 134fe182008dc13a16f12d723aa73771efb1a6a2 (patch) | |
tree | 727c94937346d31a5e2692546d16296f069d09fe /app/controllers/projects/raw_controller.rb | |
parent | 6a7cc8c14727f6fac64a5be6838764d8d5d41468 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/projects/raw_controller.rb')
-rw-r--r-- | app/controllers/projects/raw_controller.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index c94fdd9483d..985587268c5 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -19,14 +19,16 @@ class Projects::RawController < Projects::ApplicationController private def show_rate_limit - limiter = ::Gitlab::ActionRateLimiter.new(action: :show_raw_controller) + if rate_limiter.throttled?(:show_raw_controller, scope: [@project, @commit, @path], threshold: raw_blob_request_limit) + rate_limiter.log_request(request, :raw_blob_request_limit, current_user) - return unless limiter.throttled?([@project, @commit, @path], raw_blob_request_limit) - - limiter.log_request(request, :raw_blob_request_limit, current_user) + flash[:alert] = _('You cannot access the raw file. Please wait a minute.') + redirect_to project_blob_path(@project, File.join(@ref, @path)), status: :too_many_requests + end + end - flash[:alert] = _('You cannot access the raw file. Please wait a minute.') - redirect_to project_blob_path(@project, File.join(@ref, @path)), status: :too_many_requests + def rate_limiter + ::Gitlab::ApplicationRateLimiter end def raw_blob_request_limit |