Rendering: Check if default image exists to avoid breaking reports if it's moved (#40930)

This commit is contained in:
Selene 2021-10-27 16:08:03 +02:00 committed by GitHub
parent 67449b95e9
commit 37cbed4b48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,9 +159,13 @@ func (rs *RenderingService) Version() string {
func (rs *RenderingService) RenderErrorImage(err error) (*RenderResult, error) {
imgUrl := "public/img/rendering_error.png"
imgPath := filepath.Join(setting.HomePath, imgUrl)
if _, err := os.Stat(imgPath); errors.Is(err, os.ErrNotExist) {
return nil, err
}
return &RenderResult{
FilePath: filepath.Join(setting.HomePath, imgUrl),
FilePath: imgPath,
}, nil
}