2015-12-18 02:41:16 -05:00
|
|
|
class Projects::ArtifactsController < Projects::ApplicationController
|
2015-12-17 08:24:43 -05:00
|
|
|
layout 'project'
|
2016-02-01 17:58:04 -05:00
|
|
|
before_action :authorize_read_build!
|
2016-06-10 10:20:11 -04:00
|
|
|
before_action :authorize_update_build!, only: [:keep]
|
2016-06-10 08:39:36 -04:00
|
|
|
before_action :validate_artifacts!
|
2015-12-17 08:24:43 -05:00
|
|
|
|
|
|
|
def download
|
|
|
|
unless artifacts_file.file_storage?
|
|
|
|
return redirect_to artifacts_file.url
|
|
|
|
end
|
|
|
|
|
|
|
|
send_file artifacts_file.path, disposition: 'attachment'
|
|
|
|
end
|
|
|
|
|
2015-12-18 02:41:16 -05:00
|
|
|
def browse
|
2016-01-11 03:57:03 -05:00
|
|
|
directory = params[:path] ? "#{params[:path]}/" : ''
|
2016-01-13 15:17:28 -05:00
|
|
|
@entry = build.artifacts_metadata_entry(directory)
|
2016-01-11 03:57:03 -05:00
|
|
|
|
2016-01-13 15:17:28 -05:00
|
|
|
return render_404 unless @entry.exists?
|
2015-12-17 09:17:00 -05:00
|
|
|
end
|
|
|
|
|
2016-01-09 08:41:43 -05:00
|
|
|
def file
|
2016-01-13 15:17:28 -05:00
|
|
|
entry = build.artifacts_metadata_entry(params[:path])
|
2016-01-11 04:01:18 -05:00
|
|
|
|
2016-01-13 15:17:28 -05:00
|
|
|
if entry.exists?
|
2016-07-05 10:58:38 -04:00
|
|
|
send_artifacts_entry(build, entry)
|
2016-01-11 04:01:18 -05:00
|
|
|
else
|
2016-07-11 08:04:27 -04:00
|
|
|
render_404
|
2016-01-11 04:01:18 -05:00
|
|
|
end
|
2016-01-09 08:41:43 -05:00
|
|
|
end
|
|
|
|
|
2016-06-08 11:18:54 -04:00
|
|
|
def keep
|
|
|
|
build.keep_artifacts!
|
|
|
|
redirect_to namespace_project_build_path(project.namespace, project, build)
|
|
|
|
end
|
|
|
|
|
2015-12-17 08:24:43 -05:00
|
|
|
private
|
|
|
|
|
2016-06-10 08:39:36 -04:00
|
|
|
def validate_artifacts!
|
|
|
|
render_404 unless build.artifacts?
|
|
|
|
end
|
|
|
|
|
2015-12-17 08:24:43 -05:00
|
|
|
def build
|
2016-06-03 18:02:40 -04:00
|
|
|
@build ||= project.builds.find_by!(id: params[:build_id])
|
2015-12-17 08:24:43 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def artifacts_file
|
|
|
|
@artifacts_file ||= build.artifacts_file
|
|
|
|
end
|
|
|
|
end
|