From 274b9b6032572dd33b28815a9c13bb18a02becbe Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Mon, 20 Feb 2017 13:40:32 -0500 Subject: Fixing file info caching issue with Aurora for master (#5477) --- app/file.go | 2 +- app/notification.go | 10 +++++++--- app/post.go | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/file.go b/app/file.go index 2ac3c398a..b678475c9 100644 --- a/app/file.go +++ b/app/file.go @@ -319,7 +319,7 @@ func MigrateFilenamesToFileInfos(post *model.Post) []*model.FileInfo { return []*model.FileInfo{} } else if newPost := result.Data.(*model.PostList).Posts[post.Id]; len(newPost.Filenames) != len(post.Filenames) { // Another thread has already created FileInfos for this post, so just return those - if result := <-Srv.Store.FileInfo().GetForPost(post.Id, false); result.Err != nil { + if result := <-Srv.Store.FileInfo().GetForPost(post.Id, true, false); result.Err != nil { l4g.Error(utils.T("api.file.migrate_filenames_to_file_infos.get_post_file_infos_again.app_error"), post.Id, result.Err) return []*model.FileInfo{} } else { diff --git a/app/notification.go b/app/notification.go index e707b3d22..1df194d2c 100644 --- a/app/notification.go +++ b/app/notification.go @@ -26,7 +26,11 @@ import ( func SendNotifications(post *model.Post, team *model.Team, channel *model.Channel, sender *model.User) ([]string, *model.AppError) { pchan := Srv.Store.User().GetAllProfilesInChannel(channel.Id, true) - fchan := Srv.Store.FileInfo().GetForPost(post.Id, true) + var fchan store.StoreChannel + + if len(post.FileIds) != 0 { + fchan = Srv.Store.FileInfo().GetForPost(post.Id, true, true) + } var profileMap map[string]*model.User if result := <-pchan; result.Err != nil { @@ -268,7 +272,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe message.Add("sender_name", senderUsername) message.Add("team_id", team.Id) - if len(post.FileIds) != 0 { + if len(post.FileIds) != 0 && fchan != nil { message.Add("otherFile", "true") var infos []*model.FileInfo @@ -410,7 +414,7 @@ func GetMessageForNotification(post *model.Post, translateFunc i18n.TranslateFun // extract the filenames from their paths and determine what type of files are attached var infos []*model.FileInfo - if result := <-Srv.Store.FileInfo().GetForPost(post.Id, true); result.Err != nil { + if result := <-Srv.Store.FileInfo().GetForPost(post.Id, true, true); result.Err != nil { l4g.Warn(utils.T("api.post.get_message_for_notification.get_files.error"), post.Id, result.Err) } else { infos = result.Data.([]*model.FileInfo) diff --git a/app/post.go b/app/post.go index 78f56a607..a89a72e62 100644 --- a/app/post.go +++ b/app/post.go @@ -463,9 +463,9 @@ func SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bo return posts, nil } -func GetFileInfosForPost(postId string) ([]*model.FileInfo, *model.AppError) { +func GetFileInfosForPost(postId string, readFromMaster bool) ([]*model.FileInfo, *model.AppError) { pchan := Srv.Store.Post().GetSingle(postId) - fchan := Srv.Store.FileInfo().GetForPost(postId, true) + fchan := Srv.Store.FileInfo().GetForPost(postId, readFromMaster, true) var infos []*model.FileInfo if result := <-fchan; result.Err != nil { -- cgit v1.2.3-1-g7c22