fix: handle error from InvalidateAllCaches in slack.go (#30606)

* fix: hanlde error from InvalidateAllCaches in slack.go

* change signature of InvalidateAllCaches to *model.AppError

* return  err from InvalidateAllCaches everywhere

* Formatting

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
kasyap dharanikota
2025-04-14 13:54:21 +05:30
коммит произвёл GitHub
родитель d808bc94e9
Коммит ae046fb34e
5 изменённых файлов: 15 добавлений и 9 удалений

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

@@ -103,7 +103,6 @@ issues:
channels/app/platform/status.go|\
channels/app/platform/web_hub_test.go|\
channels/app/post_test.go|\
channels/app/slack.go|\
channels/app/slashcommands/auto_environment.go|\
channels/app/slashcommands/command_test.go|\
channels/app/slashcommands/helper_test.go|\

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

@@ -145,8 +145,8 @@ func (s *Server) InvalidateAllCaches() *model.AppError {
return s.platform.InvalidateAllCaches()
}
func (s *Server) InvalidateAllCachesSkipSend() {
s.platform.InvalidateAllCachesSkipSend()
func (s *Server) InvalidateAllCachesSkipSend() *model.AppError {
return s.platform.InvalidateAllCachesSkipSend()
}
func (a *App) RecycleDatabaseConnection(rctx request.CTX) {

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

@@ -52,7 +52,9 @@ func (ps *PlatformService) ClusterUpdateStatusHandler(msg *model.ClusterMessage)
}
func (ps *PlatformService) ClusterInvalidateAllCachesHandler(msg *model.ClusterMessage) {
ps.InvalidateAllCachesSkipSend()
if err := ps.InvalidateAllCachesSkipSend(); err != nil {
ps.logger.Error("Error validating caches from cluster message", mlog.Err(err))
}
}
func (ps *PlatformService) clusterInvalidateWebConnSessionCacheForUserHandler(msg *model.ClusterMessage) {
@@ -98,7 +100,7 @@ func (ps *PlatformService) invalidateWebConnSessionCacheForUserSkipClusterSend(u
}
}
func (ps *PlatformService) InvalidateAllCachesSkipSend() {
func (ps *PlatformService) InvalidateAllCachesSkipSend() *model.AppError {
ps.logger.Info("Purging all caches")
ps.ClearAllUsersSessionCacheLocal()
if err := ps.statusCache.Purge(); err != nil {
@@ -115,10 +117,13 @@ func (ps *PlatformService) InvalidateAllCachesSkipSend() {
ps.logger.Warn("Failed to clear the link cache", mlog.Err(err))
}
ps.LoadLicense()
return nil
}
func (ps *PlatformService) InvalidateAllCaches() *model.AppError {
ps.InvalidateAllCachesSkipSend()
if err := ps.InvalidateAllCachesSkipSend(); err != nil {
return err
}
if ps.clusterIFace != nil {
msg := &model.ClusterMessage{

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

@@ -38,7 +38,7 @@ func (a *App) SlackImport(c request.CTX, fileData multipart.File, fileSize int64
},
GenerateThumbnailImage: a.generateThumbnailImage,
GeneratePreviewImage: a.generatePreviewImage,
InvalidateAllCaches: func() { a.ch.srv.InvalidateAllCaches() },
InvalidateAllCaches: func() *model.AppError { return a.ch.srv.platform.InvalidateAllCaches() },
MaxPostSize: func() int { return a.ch.srv.platform.MaxPostSize() },
PrepareImage: func(fileData []byte) (image.Image, string, func(), error) {
img, imgType, release, err := prepareImage(c, a.ch.imgDecoder, bytes.NewReader(fileData))

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

@@ -93,7 +93,7 @@ type Actions struct {
DoUploadFile func(time.Time, string, string, string, string, []byte) (*model.FileInfo, *model.AppError)
GenerateThumbnailImage func(request.CTX, image.Image, string, string)
GeneratePreviewImage func(request.CTX, image.Image, string, string)
InvalidateAllCaches func()
InvalidateAllCaches func() *model.AppError
MaxPostSize func() int
PrepareImage func(fileData []byte) (image.Image, string, func(), error)
}
@@ -210,7 +210,9 @@ func (si *SlackImporter) SlackImport(rctx request.CTX, fileData multipart.File,
si.deactivateSlackBotUser(rctx, botUser)
}
si.actions.InvalidateAllCaches()
if err := si.actions.InvalidateAllCaches(); err != nil {
return err, log
}
log.WriteString(i18n.T("api.slackimport.slack_import.notes"))
log.WriteString("=======\r\n\r\n")