[MM-48946] Fix read after write issue when uploading data (#21868)

* Fix read after write issue when uploading data

* Prefer request.CTX interface
Этот коммит содержится в:
Claudio Costa
2022-12-13 11:47:05 -06:00
коммит произвёл GitHub
родитель 68373e992b
Коммит 6fd174a95f
13 изменённых файлов: 45 добавлений и 34 удалений

Просмотреть файл

@@ -1255,7 +1255,9 @@ func (api *PluginAPI) UploadData(us *model.UploadSession, rd io.Reader) (*model.
}
func (api *PluginAPI) GetUploadSession(uploadID string) (*model.UploadSession, error) {
fi, err := api.app.GetUploadSession(uploadID)
// We want to fetch from master DB to avoid a potential read-after-write on the plugin side.
api.ctx.SetContext(WithMaster(api.ctx.Context()))
fi, err := api.app.GetUploadSession(api.ctx, uploadID)
if err != nil {
return nil, err
}