diff options
author | 99rgosse <61579380+99rgosse@users.noreply.github.com> | 2022-05-02 18:46:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-02 18:46:50 +0200 |
commit | 438646e0b55138d2b18313142072236e8f178c29 (patch) | |
tree | b51c77a2399d7913569d6a5eae8f383cd561caaa /routers | |
parent | c18d8d6968cb175703942631f0094ffb415f51f4 (diff) | |
download | gitea-438646e0b55138d2b18313142072236e8f178c29.tar.gz gitea-438646e0b55138d2b18313142072236e8f178c29.zip |
Handle the error of a missing blob object fix #19530 (#19552)
* Handle the error of a missing blob object
* Show error in logs
* as per @zeripath
* Add missing error check
* Add missing error check
* Update compare.go
* Use formal code
* Update compare.go
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/compare.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 7721507bae..d483227ebf 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -143,6 +143,11 @@ func setCsvCompareContext(ctx *context.Context) { if err == errTooLarge { return CsvDiffResult{nil, err.Error()} } + if err != nil { + log.Error("CreateCsvDiff error whilst creating baseReader from file %s in commit %s in %s: %v", diffFile.Name, baseCommit.ID.String(), ctx.Repo.Repository.Name, err) + return CsvDiffResult{nil, "unable to load file from base commit"} + } + headReader, headBlobCloser, err := csvReaderFromCommit(&markup.RenderContext{Ctx: ctx, Filename: diffFile.Name}, headCommit) if headBlobCloser != nil { defer headBlobCloser.Close() @@ -150,13 +155,17 @@ func setCsvCompareContext(ctx *context.Context) { if err == errTooLarge { return CsvDiffResult{nil, err.Error()} } + if err != nil { + log.Error("CreateCsvDiff error whilst creating headReader from file %s in commit %s in %s: %v", diffFile.Name, headCommit.ID.String(), ctx.Repo.Repository.Name, err) + return CsvDiffResult{nil, "unable to load file from head commit"} + } sections, err := gitdiff.CreateCsvDiff(diffFile, baseReader, headReader) if err != nil { errMessage, err := csv_module.FormatError(err, ctx.Locale) if err != nil { - log.Error("RenderCsvDiff failed: %v", err) - return CsvDiffResult{nil, ""} + log.Error("CreateCsvDiff FormatError failed: %v", err) + return CsvDiffResult{nil, "unknown csv diff error"} } return CsvDiffResult{nil, errMessage} } |