diff options
author | Corey Hulen <corey@hulen.com> | 2017-02-20 13:40:32 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-02-20 13:40:32 -0500 |
commit | 274b9b6032572dd33b28815a9c13bb18a02becbe (patch) | |
tree | 1fd47c65c854117d698d92b5cef701b59d4f9ebc /api | |
parent | dd4d8440eac2e4b64bfb6b449cc0668b78ecba50 (diff) | |
download | chat-274b9b6032572dd33b28815a9c13bb18a02becbe.tar.gz chat-274b9b6032572dd33b28815a9c13bb18a02becbe.tar.bz2 chat-274b9b6032572dd33b28815a9c13bb18a02becbe.zip |
Fixing file info caching issue with Aurora for master (#5477)
Diffstat (limited to 'api')
-rw-r--r-- | api/post.go | 7 | ||||
-rw-r--r-- | api/post_test.go | 2 |
2 files changed, 6 insertions, 3 deletions
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") |