Commit b17df050 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Extract ref_name and path in before_action, feedback:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_14469768
parent 6a2d2bd1
...@@ -4,6 +4,7 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -4,6 +4,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
layout 'project' layout 'project'
before_action :authorize_read_build! before_action :authorize_read_build!
before_action :authorize_update_build!, only: [:keep] before_action :authorize_update_build!, only: [:keep]
before_action :extract_ref_name_and_path
before_action :validate_artifacts! before_action :validate_artifacts!
def download def download
...@@ -48,6 +49,12 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -48,6 +49,12 @@ class Projects::ArtifactsController < Projects::ApplicationController
private private
def extract_ref_name_and_path
return unless params[:ref_name_and_path]
@ref_name, @path = extract_ref(params[:ref_name_and_path])
end
def validate_artifacts! def validate_artifacts!
render_404 unless build && build.artifacts? render_404 unless build && build.artifacts?
end end
...@@ -61,12 +68,10 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -61,12 +68,10 @@ class Projects::ArtifactsController < Projects::ApplicationController
end end
def build_from_ref def build_from_ref
if params[:ref_name_and_path] return unless @ref_name
ref_name, @path = extract_ref(params[:ref_name_and_path])
builds = project.latest_successful_builds_for(ref_name)
builds.find_by(name: params[:job]) builds = project.latest_successful_builds_for(@ref_name)
end builds.find_by(name: params[:job])
end end
def artifacts_file def artifacts_file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment