summaryrefslogtreecommitdiffstats
path: root/model/manifest.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-07-31 16:29:52 -0400
committerGitHub <noreply@github.com>2018-07-31 16:29:52 -0400
commit0788cdcadfb5d76b08758f42f01521b45ea76362 (patch)
tree86efb424a0543571398866e3cb84ee38be101141 /model/manifest.go
parent8c56f52d17d73a431a060919c97fe8939f81a0d1 (diff)
downloadchat-0788cdcadfb5d76b08758f42f01521b45ea76362.tar.gz
chat-0788cdcadfb5d76b08758f42f01521b45ea76362.tar.bz2
chat-0788cdcadfb5d76b08758f42f01521b45ea76362.zip
MM-11420: plugins: compute bundle hash on load (#9172)
* plugins: compute bundle hash on load Use this hash to bust client caches whenever the plugin bundle changes. * eliminate redundant pluginHandler * switch to 64-bit FNV-1a * Fix test
Diffstat (limited to 'model/manifest.go')
-rw-r--r--model/manifest.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/model/manifest.go b/model/manifest.go
index 705cc740e..6a7df59f4 100644
--- a/model/manifest.go
+++ b/model/manifest.go
@@ -5,6 +5,7 @@ package model
import (
"encoding/json"
+ "fmt"
"io"
"io/ioutil"
"os"
@@ -151,6 +152,9 @@ type ManifestWebapp struct {
// The path to your webapp bundle. This should be relative to the root of your bundle and the
// location of the manifest file.
BundlePath string `json:"bundle_path" yaml:"bundle_path"`
+
+ // BundleHash is the 64-bit FNV-1a hash of the webapp bundle, computed when the plugin is loaded
+ BundleHash []byte `json:"-"`
}
func (m *Manifest) ToJson() string {
@@ -188,7 +192,7 @@ func (m *Manifest) ClientManifest() *Manifest {
if cm.Webapp != nil {
cm.Webapp = new(ManifestWebapp)
*cm.Webapp = *m.Webapp
- cm.Webapp.BundlePath = "/static/" + m.Id + "/" + m.Id + "_bundle.js"
+ cm.Webapp.BundlePath = "/static/" + m.Id + "/" + fmt.Sprintf("%s_%x_bundle.js", m.Id, m.Webapp.BundleHash)
}
return cm
}