From 10b412d237e7594951ab3633dc8eebb965e25f68 Mon Sep 17 00:00:00 2001 From: slene Date: Fri, 28 Mar 2014 00:50:13 +0800 Subject: [PATCH] commit raw file --- modules/base/markdown.go | 2 +- routers/repo/repo.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/base/markdown.go b/modules/base/markdown.go index a98ca8cf003d..962e1ae1e934 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -53,7 +53,7 @@ func IsTextFile(data []byte) (string, bool) { func IsImageFile(data []byte) (string, bool) { contentType := http.DetectContentType(data) - if strings.Index(contentType, "img/") != -1 { + if strings.Index(contentType, "image/") != -1 { return contentType, true } return contentType, false diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 8c686bc3d6fb..3b57cb39f6df 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -225,8 +225,18 @@ func SingleDownload(ctx *middleware.Context, params martini.Params) { // Get tree path treename := params["_1"] - repoFile, err := models.GetTargetFile(params["username"], params["reponame"], - params["branchname"], params["commitid"], treename) + branchName := params["branchname"] + userName := params["username"] + repoName := params["reponame"] + + var commitId string + if !models.IsBranchExist(userName, repoName, branchName) { + commitId = branchName + branchName = "" + } + + repoFile, err := models.GetTargetFile(userName, repoName, + branchName, commitId, treename) if err != nil { ctx.Handle(404, "repo.SingleDownload(GetTargetFile)", err)