Refactored project archive. Improved MR usability form

This commit is contained in:
Dmitriy Zaporozhets 2012-06-13 09:03:53 +03:00
parent edd81a79c5
commit a243253b10
5 changed files with 94 additions and 51 deletions

View file

@ -27,22 +27,14 @@ class RepositoriesController < ApplicationController
render_404 and return
end
ref = params[:ref] || @project.root_ref
commit = @project.commit(ref)
render_404 and return unless commit
# Build file path
file_name = @project.code + "-" + commit.id.to_s + ".tar.gz"
storage_path = File.join(Rails.root, "tmp", "repositories", @project.code)
file_path = File.join(storage_path, file_name)
file_path = @project.archive_repo(params[:ref])
# Create file if not exists
unless File.exists?(file_path)
FileUtils.mkdir_p storage_path
file = @project.repo.archive_to_file(ref, nil, file_path)
if file_path
# Send file to user
send_file file_path
else
render_404
end
# Send file to user
send_file file_path
end
end