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
layout 'project'
before_action :authorize_read_build!
before_action :authorize_update_build!, only: [:keep]
before_action :extract_ref_name_and_path
before_action :validate_artifacts!
def download
......@@ -48,6 +49,12 @@ class Projects::ArtifactsController < Projects::ApplicationController
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!
render_404 unless build && build.artifacts?
end
......@@ -61,13 +68,11 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
def build_from_ref
if params[:ref_name_and_path]
ref_name, @path = extract_ref(params[:ref_name_and_path])
builds = project.latest_successful_builds_for(ref_name)
return unless @ref_name
builds = project.latest_successful_builds_for(@ref_name)
builds.find_by(name: params[:job])
end
end
def artifacts_file
@artifacts_file ||= build.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