Skip to content

Commit

Permalink
Fix object does not exist error when checking citation file (go-gitea…
Browse files Browse the repository at this point in the history
…#28314)

Fix go-gitea#28264

`DataAsync()` will be called twice.
Caused by go-gitea#27958.
I'm sorry, I didn't completely remove all unnecessary codes.
  • Loading branch information
yp05327 authored and fuxiaohei committed Jan 17, 2024
1 parent ac8f463 commit 6c98e93
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 6c98e93

Please sign in to comment.