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 удалений

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

@@ -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))