]> source.dussan.org Git - gitea.git/commitdiff
commit raw file
authorslene <vslene@gmail.com>
Thu, 27 Mar 2014 16:50:13 +0000 (00:50 +0800)
committerslene <vslene@gmail.com>
Thu, 27 Mar 2014 16:50:13 +0000 (00:50 +0800)
modules/base/markdown.go
routers/repo/repo.go

index a98ca8cf003ded4244274844fc93b998e599b3f8..962e1ae1e934ea144329042cfef4727ce800f292 100644 (file)
@@ -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
index 8c686bc3d6fbbc7fad0bc197910fc6d80035d097..3b57cb39f6df3ebd18ac58bb810c041a48704df2 100644 (file)
@@ -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)