Validate existence of artifacts in ArtifactsController, render 404 if not found

This commit is contained in:
Kamil Trzcinski 2016-06-10 14:39:36 +02:00 committed by Phil Hughes
parent 86800bf51a
commit c59947112f

View file

@ -1,22 +1,17 @@
class Projects::ArtifactsController < Projects::ApplicationController
layout 'project'
before_action :authorize_read_build!
before_action :validate_artifacts!
def download
unless artifacts_file.file_storage?
return redirect_to artifacts_file.url
end
unless artifacts_file.exists?
return render_404
end
send_file artifacts_file.path, disposition: 'attachment'
end
def browse
return render_404 unless build.artifacts?
directory = params[:path] ? "#{params[:path]}/" : ''
@entry = build.artifacts_metadata_entry(directory)
@ -41,6 +36,10 @@ class Projects::ArtifactsController < Projects::ApplicationController
private
def validate_artifacts!
render_404 unless build.artifacts?
end
def build
@build ||= project.builds.find_by!(id: params[:build_id])
end