summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-07 12:36:37 -0800
committerGitHub <noreply@github.com>2017-02-07 12:36:37 -0800
commit487bb56a9b8f5c7a9efaabfc631f2f6c689ef74b (patch)
treea92bcbe004045581752c33dfd126c211300cda25 /app
parenteb767d2c1cb65724f25479144d68a9d102d32dfa (diff)
downloadchat-487bb56a9b8f5c7a9efaabfc631f2f6c689ef74b.tar.gz
chat-487bb56a9b8f5c7a9efaabfc631f2f6c689ef74b.tar.bz2
chat-487bb56a9b8f5c7a9efaabfc631f2f6c689ef74b.zip
Add caching for file infos (#5330)
Diffstat (limited to 'app')
-rw-r--r--app/file.go2
-rw-r--r--app/notification.go4
-rw-r--r--app/post.go3
3 files changed, 5 insertions, 4 deletions
diff --git a/app/file.go b/app/file.go
index 4ddf7ac2d..095e4d032 100644
--- a/app/file.go
+++ b/app/file.go
@@ -318,7 +318,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); result.Err != nil {
+ if result := <-Srv.Store.FileInfo().GetForPost(post.Id, 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 cc4e13ab1..1550c0393 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -26,7 +26,7 @@ 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)
+ fchan := Srv.Store.FileInfo().GetForPost(post.Id, true)
var profileMap map[string]*model.User
if result := <-pchan; result.Err != nil {
@@ -414,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); result.Err != nil {
+ if result := <-Srv.Store.FileInfo().GetForPost(post.Id, 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 82fc733b4..5fddd3e78 100644
--- a/app/post.go
+++ b/app/post.go
@@ -457,7 +457,7 @@ func SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bo
func GetFileInfosForPost(postId string) ([]*model.FileInfo, *model.AppError) {
pchan := Srv.Store.Post().Get(postId)
- fchan := Srv.Store.FileInfo().GetForPost(postId)
+ fchan := Srv.Store.FileInfo().GetForPost(postId, true)
var infos []*model.FileInfo
if result := <-fchan; result.Err != nil {
@@ -476,6 +476,7 @@ func GetFileInfosForPost(postId string) ([]*model.FileInfo, *model.AppError) {
}
if len(post.Filenames) > 0 {
+ Srv.Store.FileInfo().InvalidateFileInfosForPostCache(postId)
// The post has Filenames that need to be replaced with FileInfos
infos = MigrateFilenamesToFileInfos(post)
}