2013-06-23 16:47:22 +00:00
|
|
|
class Projects::RepositoriesController < Projects::ApplicationController
|
2011-12-30 20:56:13 +00:00
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_read_project!
|
2012-02-21 22:31:18 +00:00
|
|
|
before_filter :authorize_code_access!
|
2011-12-30 20:56:13 +00:00
|
|
|
before_filter :require_non_empty_project
|
|
|
|
|
2012-11-10 21:08:47 +00:00
|
|
|
def stats
|
2013-04-03 18:05:10 +00:00
|
|
|
@stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref)
|
2012-11-10 21:08:47 +00:00
|
|
|
@graph = @stats.graph
|
|
|
|
end
|
|
|
|
|
2012-02-07 23:00:49 +00:00
|
|
|
def archive
|
|
|
|
unless can?(current_user, :download_code, @project)
|
2012-11-10 21:08:47 +00:00
|
|
|
render_404 and return
|
2012-02-07 23:00:49 +00:00
|
|
|
end
|
|
|
|
|
2014-03-28 12:09:25 +00:00
|
|
|
storage_path = Gitlab.config.gitlab.repository_downloads_path
|
2013-04-29 06:15:18 +00:00
|
|
|
|
2014-04-09 13:09:11 +00:00
|
|
|
@repository.clean_old_archives
|
|
|
|
|
2013-12-20 19:12:44 +00:00
|
|
|
file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase)
|
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
|
|
|
|
render_404
|
|
|
|
end
|
2012-02-07 23:00:49 +00:00
|
|
|
end
|
2011-12-30 20:56:13 +00:00
|
|
|
end
|