Refactored project archive. Improved MR usability form
This commit is contained in:
parent
edd81a79c5
commit
a243253b10
5 changed files with 94 additions and 51 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue