4d0d5e79ba
with existing method_missing. Pattern already used extensively, so let's be consistent and use it everywhere.
22 lines
603 B
Ruby
22 lines
603 B
Ruby
class Projects::RepositoriesController < Projects::ApplicationController
|
|
# Authorize
|
|
before_filter :authorize_read_project!
|
|
before_filter :authorize_download_code!
|
|
before_filter :require_non_empty_project
|
|
|
|
def archive
|
|
unless can?(current_user, :download_code, @project)
|
|
render_404 and return
|
|
end
|
|
|
|
file_path = ArchiveRepositoryService.new.execute(@project, params[:ref], params[:format])
|
|
|
|
if file_path
|
|
# Send file to user
|
|
response.headers["Content-Length"] = File.open(file_path).size.to_s
|
|
send_file file_path
|
|
else
|
|
render_404
|
|
end
|
|
end
|
|
end
|