Fix a bug where the tgz returned got encoded utf8

Conflicts:
	doc/api/repositories.md

Change-Id: I7ebc39b47ff860813d9622ba6776583536e6e384
This commit is contained in:
Izaak Alpert 2013-10-02 10:47:23 -04:00
parent ce21d8688d
commit a00c534c4c
2 changed files with 10 additions and 6 deletions

View file

@ -368,4 +368,4 @@ GET /projects/:id/repository/archive
Parameters: Parameters:
+ `id` (required) - The ID of a project + `id` (required) - The ID of a project
+ `sha` (optional) - The commit or branch name + `sha` (optional) - The commit sha to download defaults to the tip of the default branch

View file

@ -181,7 +181,7 @@ module API
# #
# Parameters: # Parameters:
# id (required) - The ID of a project # 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: # Example Request:
# GET /projects/:id/repository/archive # GET /projects/:id/repository/archive
get ":id/repository/archive" do get ":id/repository/archive" do
@ -190,11 +190,15 @@ module API
ref = params[:sha] ref = params[:sha]
storage_path = Rails.root.join("tmp", "repositories") storage_path = Rails.root.join("tmp", "repositories")
file_path = repo.archive_repo(ref || 'HEAD', storage_path) file_path = repo.archive_repo(ref, storage_path)
if file_path if file_path && File.exists?(file_path)
data = File.open(file_path).read data = File.open(file_path, 'rb').read
content_type 'application/x-gzip'
header "Content-Disposition:", " infile; filename=\"#{File.basename(file_path)}\"" header "Content-Disposition:", " infile; filename=\"#{File.basename(file_path)}\""
content_type 'application/x-gzip'
env['api.format'] = :binary
present data present data
else else
not_found! not_found!