summaryrefslogtreecommitdiff
path: root/app/controllers/repositories_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/repositories_controller.rb')
-rw-r--r--app/controllers/repositories_controller.rb24
1 files changed, 8 insertions, 16 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 036eb3713bf..cd20677e1ad 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -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)
-
- # 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)
- end
- # Send file to user
- send_file file_path
+ file_path = @project.archive_repo(params[:ref])
+
+ if file_path
+ # Send file to user
+ send_file file_path
+ else
+ render_404
+ end
end
end