From 23eec252748c3ac7af2ae310aeac4ee4c9061fe9 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 6 Nov 2014 22:06:41 -0500 Subject: Fix #605, fix #255, fix #101 --- routers/repo/download.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'routers/repo/download.go') diff --git a/routers/repo/download.go b/routers/repo/download.go index abb9b062..17642a57 100644 --- a/routers/repo/download.go +++ b/routers/repo/download.go @@ -13,9 +13,7 @@ import ( ) func SingleDownload(ctx *middleware.Context) { - treename := ctx.Params("*") - - blob, err := ctx.Repo.Commit.GetBlobByPath(treename) + blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreeName) if err != nil { ctx.Handle(500, "GetBlobByPath", err) return @@ -23,7 +21,7 @@ func SingleDownload(ctx *middleware.Context) { dataRc, err := blob.Data() if err != nil { - ctx.Handle(500, "repo.SingleDownload(Data)", err) + ctx.Handle(500, "Data", err) return } @@ -37,7 +35,7 @@ func SingleDownload(ctx *middleware.Context) { _, isImageFile := base.IsImageFile(buf) ctx.Resp.Header().Set("Content-Type", contentType) if !isTextFile && !isImageFile { - ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+path.Base(treename)) + ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+path.Base(ctx.Repo.TreeName)) ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary") } ctx.Resp.Write(buf) -- cgit v1.2.3