summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-02-20 13:40:32 -0500
committerChristopher Speller <crspeller@gmail.com>2017-02-20 13:40:32 -0500
commit274b9b6032572dd33b28815a9c13bb18a02becbe (patch)
tree1fd47c65c854117d698d92b5cef701b59d4f9ebc /app
parentdd4d8440eac2e4b64bfb6b449cc0668b78ecba50 (diff)
downloadchat-274b9b6032572dd33b28815a9c13bb18a02becbe.tar.gz
chat-274b9b6032572dd33b28815a9c13bb18a02becbe.tar.bz2
chat-274b9b6032572dd33b28815a9c13bb18a02becbe.zip
Fixing file info caching issue with Aurora for master (#5477)
Diffstat (limited to 'app')
-rw-r--r--app/file.go2
-rw-r--r--app/notification.go10
-rw-r--r--app/post.go4
3 files changed, 10 insertions, 6 deletions
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 {