2013-06-23 16:47:22 +00:00
|
|
|
class Projects::RepositoriesController < Projects::ApplicationController
|
2011-12-30 20:56:13 +00:00
|
|
|
# Authorize
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :require_non_empty_project, except: :create
|
|
|
|
before_action :authorize_download_code!
|
|
|
|
before_action :authorize_admin_project!, only: :create
|
2014-11-29 22:50:25 +00:00
|
|
|
|
|
|
|
def create
|
|
|
|
@project.create_repository
|
|
|
|
|
2015-02-26 03:34:16 +00:00
|
|
|
redirect_to project_path(@project)
|
2014-11-29 22:50:25 +00:00
|
|
|
end
|
2011-12-30 20:56:13 +00:00
|
|
|
|
2012-02-07 23:00:49 +00:00
|
|
|
def archive
|
2015-03-24 12:15:59 +00:00
|
|
|
begin
|
|
|
|
file_path = ArchiveRepositoryService.new(@project, params[:ref], params[:format]).execute
|
|
|
|
rescue
|
2015-03-31 11:37:21 +00:00
|
|
|
return head :not_found
|
2015-03-24 12:15:59 +00:00
|
|
|
end
|
2012-06-13 06:03:53 +00:00
|
|
|
|
|
|
|
if file_path
|
|
|
|
# Send file to user
|
2014-07-08 11:55:20 +00:00
|
|
|
response.headers["Content-Length"] = File.open(file_path).size.to_s
|
2012-06-13 06:03:53 +00:00
|
|
|
send_file file_path
|
|
|
|
else
|
2015-03-24 12:15:59 +00:00
|
|
|
redirect_to request.fullpath
|
2012-06-13 06:03:53 +00:00
|
|
|
end
|
2012-02-07 23:00:49 +00:00
|
|
|
end
|
2011-12-30 20:56:13 +00:00
|
|
|
end
|