debian-mirror-gitlab/app/controllers/projects/repositories_controller.rb

29 lines
712 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Projects::RepositoriesController < Projects::ApplicationController
# Authorize
2015-09-11 14:41:01 +05:30
before_action :require_non_empty_project, except: :create
before_action :authorize_download_code!
before_action :authorize_admin_project!, only: :create
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
def create
@project.create_repository
redirect_to project_path(@project)
2014-09-02 18:07:02 +05:30
end
def archive
2015-04-26 12:48:37 +05:30
begin
file_path = ArchiveRepositoryService.new(@project, params[:ref], params[:format]).execute
rescue
return head :not_found
2014-09-02 18:07:02 +05:30
end
if file_path
# Send file to user
response.headers["Content-Length"] = File.open(file_path).size.to_s
send_file file_path
else
2015-04-26 12:48:37 +05:30
redirect_to request.fullpath
2014-09-02 18:07:02 +05:30
end
end
end