mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-11649: Fix caching issue in channel API endpoints. (#9345)
This fixes an issue where the cached Channel objects would contain data from a failed update when the update to the database failed.
This commit is contained in:
committed by
Carlos Tadeu Panato Junior
parent
d2190527ea
commit
72258266aa
@@ -97,10 +97,11 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var oldChannel *model.Channel
|
||||
var err *model.AppError
|
||||
if oldChannel, err = c.App.GetChannel(channel.Id); err != nil {
|
||||
if originalOldChannel, err := c.App.GetChannel(channel.Id); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else {
|
||||
oldChannel = originalOldChannel.DeepCopy()
|
||||
}
|
||||
|
||||
switch oldChannel.Type {
|
||||
@@ -229,10 +230,12 @@ func patchChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
oldChannel, err := c.App.GetChannel(c.Params.ChannelId)
|
||||
if err != nil {
|
||||
var oldChannel *model.Channel
|
||||
if originalOldChannel, err := c.App.GetChannel(c.Params.ChannelId); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else {
|
||||
oldChannel = originalOldChannel.DeepCopy()
|
||||
}
|
||||
|
||||
switch oldChannel.Type {
|
||||
|
||||
@@ -59,6 +59,9 @@ type ChannelPatch struct {
|
||||
|
||||
func (o *Channel) DeepCopy() *Channel {
|
||||
copy := *o
|
||||
if copy.SchemeId != nil {
|
||||
copy.SchemeId = NewString(*o.SchemeId)
|
||||
}
|
||||
return ©
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user