2013-06-23 12:47:22 -04:00
|
|
|
class Projects::RepositoriesController < Projects::ApplicationController
|
2011-12-30 15:56:13 -05:00
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_read_project!
|
2012-02-21 17:31:18 -05:00
|
|
|
before_filter :authorize_code_access!
|
2011-12-30 15:56:13 -05:00
|
|
|
before_filter :require_non_empty_project
|
|
|
|
|
2012-02-07 18:00:49 -05:00
|
|
|
def archive
|
|
|
|
unless can?(current_user, :download_code, @project)
|
2012-11-10 16:08:47 -05:00
|
|
|
render_404 and return
|
2012-02-07 18:00:49 -05:00
|
|
|
end
|
|
|
|
|
2014-08-13 14:28:22 -04:00
|
|
|
file_path = ArchiveRepositoryService.new.execute(@project, params[:ref], params[:format])
|
2012-06-13 02:03:53 -04:00
|
|
|
|
|
|
|
if file_path
|
|
|
|
# Send file to user
|
2014-07-08 07:55:20 -04:00
|
|
|
response.headers["Content-Length"] = File.open(file_path).size.to_s
|
2012-06-13 02:03:53 -04:00
|
|
|
send_file file_path
|
|
|
|
else
|
|
|
|
render_404
|
|
|
|
end
|
2012-02-07 18:00:49 -05:00
|
|
|
end
|
2011-12-30 15:56:13 -05:00
|
|
|
end
|