فهرست منبع

[GinR] Nil capture should not be dereferenced

cgars 7 سال پیش
والد
کامیت
901683b266
2فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 2 2
      routes/repo/download.go
  2. 2 2
      routes/repo/view.go

+ 2 - 2
routes/repo/download.go

@@ -33,8 +33,8 @@ func ServeData(c *context.Context, name string, reader io.Reader, cpt *captcha.C
 		if err != nil {
 
 		}
-		if af.Info.Size() > gannex.MEGABYTE*setting.Repository.RawCaptchaMinFileSize && !cpt.VerifyReq(c.Req) &&
-			!c.IsLogged && !(cpt==nil){
+		if cpt!=nil && af.Info.Size() > gannex.MEGABYTE*setting.Repository.RawCaptchaMinFileSize && !cpt.VerifyReq(c.Req) &&
+			!c.IsLogged {
 			c.Data["EnableCaptcha"] = true
 			c.HTML(200, "repo/download")
 			return nil

+ 2 - 2
routes/repo/view.go

@@ -67,7 +67,7 @@ func renderDirectory(c *context.Context, treeLink string) {
 	c.Data["DOI"] = false
 	var readmeFile *git.Blob
 	for _, entry := range entries {
-		if entry.IsDir() || (!markup.IsReadmeFile(entry.Name()) && !(entry.Name() == "datacite.yml")&& !(entry.Name() == "LICENSE")) {
+		if entry.IsDir() || (!markup.IsReadmeFile(entry.Name()) && !(entry.Name() == "datacite.yml") && !(entry.Name() == "LICENSE")) {
 			continue
 		}
 
@@ -278,7 +278,7 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
 			fallthrough
 		case markup.YAML:
 			c.Data["IsYAML"] = true
-			c.Data["RawFileContent"]=string(buf)
+			c.Data["RawFileContent"] = string(buf)
 			fallthrough
 		case markup.UNRECOGNIZED:
 			if tool.IsOdmlFile(buf) {