0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-28 18:34:10 -05:00

Fix object does not exist error when checking citation file (#28314) (#28369)

Backport #28314 by @yp05327

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.

Co-authored-by: yp05327 <576951401@qq.com>
This commit is contained in:
Giteabot 2023-12-07 06:06:51 +08:00 committed by GitHub
parent 8f2805f757
commit c5c44d0951
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -702,24 +702,17 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
} }
for _, entry := range allEntries { for _, entry := range allEntries {
if entry.Name() == "CITATION.cff" || entry.Name() == "CITATION.bib" { if entry.Name() == "CITATION.cff" || entry.Name() == "CITATION.bib" {
ctx.Data["CitiationExist"] = true
// Read Citation file contents // Read Citation file contents
blob := entry.Blob() if content, err := entry.Blob().GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
dataRc, err := blob.DataAsync() log.Error("checkCitationFile: GetBlobContent: %v", err)
if err != nil { } else {
ctx.ServerError("DataAsync", err) ctx.Data["CitiationExist"] = true
return ctx.PageData["citationFileContent"] = content
}
defer dataRc.Close()
ctx.PageData["citationFileContent"], err = blob.GetBlobContent(setting.UI.MaxDisplayFileSize)
if err != nil {
ctx.ServerError("GetBlobContent", err)
return
}
break break
} }
} }
} }
}
// Home render repository home page // Home render repository home page
func Home(ctx *context.Context) { func Home(ctx *context.Context) {