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) --- api/post.go | 7 +++++-- api/post_test.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'api') diff --git a/api/post.go b/api/post.go index 28c81b9a5..b6539ed54 100644 --- a/api/post.go +++ b/api/post.go @@ -421,13 +421,16 @@ func getFileInfosForPost(c *Context, w http.ResponseWriter, r *http.Request) { return } - if infos, err := app.GetFileInfosForPost(postId); err != nil { + if infos, err := app.GetFileInfosForPost(postId, false); err != nil { c.Err = err return } else if HandleEtag(model.GetEtagForFileInfos(infos), "Get File Infos For Post", w, r) { return } else { - w.Header().Set("Cache-Control", "max-age=2592000, public") + if len(infos) > 0 { + w.Header().Set("Cache-Control", "max-age=2592000, public") + } + w.Header().Set(model.HEADER_ETAG_SERVER, model.GetEtagForFileInfos(infos)) w.Write([]byte(model.FileInfosToJson(infos))) } diff --git a/api/post_test.go b/api/post_test.go index ddcce2e59..a41781dae 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -136,7 +136,7 @@ func TestCreatePost(t *testing.T) { } else if rpost9 := resp.Data.(*model.Post); len(rpost9.FileIds) != 3 { t.Fatal("post should have 3 files") } else { - infos := store.Must(app.Srv.Store.FileInfo().GetForPost(rpost9.Id, true)).([]*model.FileInfo) + infos := store.Must(app.Srv.Store.FileInfo().GetForPost(rpost9.Id, true, true)).([]*model.FileInfo) if len(infos) != 3 { t.Fatal("should've attached all 3 files to post") -- cgit v1.2.3-1-g7c22