aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-12-06 17:51:01 +0900
committerGitHub <noreply@github.com>2023-12-06 16:51:01 +0800
commitec90ee61ef60eb02a3145c06b11d97cdea7c4af8 (patch)
treeebb2ce7432ba1bb6f4a2790c2b76a3fc9bc38e70
parent09d50284422aa70af47c77e20b65b9f5c5e32c13 (diff)
downloadgitea-ec90ee61ef60eb02a3145c06b11d97cdea7c4af8.tar.gz
gitea-ec90ee61ef60eb02a3145c06b11d97cdea7c4af8.zip
Fix object does not exist error when checking citation file (#28314)
Fix #28264 `DataAsync()` will be called twice. Caused by https://github.com/go-gitea/gitea/pull/27958. I'm sorry, I didn't completely remove all unnecessary codes.
-rw-r--r--routers/web/repo/view.go19
1 files changed, 6 insertions, 13 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index ba2ac3af11..70556185bb 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -711,21 +711,14 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
}
for _, entry := range allEntries {
if entry.Name() == "CITATION.cff" || entry.Name() == "CITATION.bib" {
- ctx.Data["CitiationExist"] = true
// Read Citation file contents
- blob := entry.Blob()
- dataRc, err := blob.DataAsync()
- if err != nil {
- ctx.ServerError("DataAsync", err)
- return
- }
- defer dataRc.Close()
- ctx.PageData["citationFileContent"], err = blob.GetBlobContent(setting.UI.MaxDisplayFileSize)
- if err != nil {
- ctx.ServerError("GetBlobContent", err)
- return
+ if content, err := entry.Blob().GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
+ log.Error("checkCitationFile: GetBlobContent: %v", err)
+ } else {
+ ctx.Data["CitiationExist"] = true
+ ctx.PageData["citationFileContent"] = content
+ break
}
- break
}
}
}