Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIzaak Alpert <ialpert@blackberry.com>2013-10-02 18:47:23 +0400
committerIzaak Alpert <ialpert@blackberry.com>2013-10-10 17:19:28 +0400
commita00c534c4c7921e40f58f714291a2bb09ad02225 (patch)
tree378503e62f636ed90b7e370b32a04327faeaffe9 /lib/api/repositories.rb
parentce21d8688d091312f47c547c2900a83fdcaebc75 (diff)
Fix a bug where the tgz returned got encoded utf8
Conflicts: doc/api/repositories.md Change-Id: I7ebc39b47ff860813d9622ba6776583536e6e384
Diffstat (limited to 'lib/api/repositories.rb')
-rw-r--r--lib/api/repositories.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index ac17aeabb13..c9422fdb165 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -181,7 +181,7 @@ module API
#
# Parameters:
# id (required) - The ID of a project
- # sha (optional) - the commit sha to download defaults to head
+ # sha (optional) - the commit sha to download defaults to the tip of the default branch
# Example Request:
# GET /projects/:id/repository/archive
get ":id/repository/archive" do
@@ -190,11 +190,15 @@ module API
ref = params[:sha]
storage_path = Rails.root.join("tmp", "repositories")
- file_path = repo.archive_repo(ref || 'HEAD', storage_path)
- if file_path
- data = File.open(file_path).read
+ file_path = repo.archive_repo(ref, storage_path)
+ if file_path && File.exists?(file_path)
+ data = File.open(file_path, 'rb').read
+
+ header "Content-Disposition:", " infile; filename=\"#{File.basename(file_path)}\""
content_type 'application/x-gzip'
- header "Content-Disposition:"," infile; filename=\"#{File.basename(file_path)}\""
+
+ env['api.format'] = :binary
+
present data
else
not_found!