Skip to content

Commit c5c44d0

Browse files
GiteaBotyp05327
andauthored
Fix object does not exist error when checking citation file (go-gitea#28314) (go-gitea#28369)
Backport go-gitea#28314 by @yp05327 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. Co-authored-by: yp05327 <[email protected]>
1 parent 8f2805f commit c5c44d0

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

routers/web/repo/view.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -702,21 +702,14 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
702702
}
703703
for _, entry := range allEntries {
704704
if entry.Name() == "CITATION.cff" || entry.Name() == "CITATION.bib" {
705-
ctx.Data["CitiationExist"] = true
706705
// Read Citation file contents
707-
blob := entry.Blob()
708-
dataRc, err := blob.DataAsync()
709-
if err != nil {
710-
ctx.ServerError("DataAsync", err)
711-
return
712-
}
713-
defer dataRc.Close()
714-
ctx.PageData["citationFileContent"], err = blob.GetBlobContent(setting.UI.MaxDisplayFileSize)
715-
if err != nil {
716-
ctx.ServerError("GetBlobContent", err)
717-
return
706+
if content, err := entry.Blob().GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
707+
log.Error("checkCitationFile: GetBlobContent: %v", err)
708+
} else {
709+
ctx.Data["CitiationExist"] = true
710+
ctx.PageData["citationFileContent"] = content
711+
break
718712
}
719-
break
720713
}
721714
}
722715
}

0 commit comments

Comments
 (0)