1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-21 13:38:56 +02:00

Avoid panic in file request handler on error (#4693)

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Doug Lauder 2023-04-03 17:43:58 -04:00 committed by GitHub
parent 1d22070454
commit 2b9eec1bec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@ import (
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/focalboard/server/services/audit"
mmModel "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
@ -167,7 +168,14 @@ func (a *API) handleServeFile(w http.ResponseWriter, r *http.Request) {
_ = a.app.MoveFile(board.ChannelID, board.TeamID, boardID, filename)
}
if err != nil {
// if err is still not nil then it is an error other than `not found` so we must
// return the error to the requestor. fileReader and Fileinfo are nil in this case.
a.errorResponse(w, r, err)
}
defer fileReader.Close()
mimeType := ""
var fileSize int64
if fileInfo != nil {