build, cmd/strelaypoolsrv: Build assets using standard script

This commit is contained in:
Jakob Borg 2016-07-04 11:22:56 +02:00
parent 59370588dd
commit ce9dc809bc
4 changed files with 6 additions and 27 deletions

View File

@ -563,16 +563,17 @@ func listFiles(dir string) []string {
func rebuildAssets() {
runPipe("lib/auto/gui.files.go", "go", "run", "script/genassets.go", "gui")
runPipe("cmd/strelaypoolsrv/auto/gui.go", "go", "run", "script/genassets.go", "cmd/strelaypoolsrv/gui")
}
func lazyRebuildAssets() {
if shouldRebuildAssets() {
if shouldRebuildAssets("lib/auto/gui.files.go", "gui") || shouldRebuildAssets("cmd/strelaypoolsrv/auto/gui.go", "cmd/strelaypoolsrv/auto/gui") {
rebuildAssets()
}
}
func shouldRebuildAssets() bool {
info, err := os.Stat("lib/auto/gui.files.go")
func shouldRebuildAssets(target, srcdir string) bool {
info, err := os.Stat(target)
if err != nil {
// If the file doesn't exist, we must rebuild it
return true
@ -582,7 +583,7 @@ func shouldRebuildAssets() bool {
// so we should rebuild it.
currentBuild := info.ModTime()
assetsAreNewer := false
filepath.Walk("gui", func(path string, info os.FileInfo, err error) error {
filepath.Walk(srcdir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}

1
cmd/strelaypoolsrv/auto/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
gui.go

File diff suppressed because one or more lines are too long

View File

@ -194,11 +194,6 @@ func handleAssets(w http.ResponseWriter, r *http.Request) {
return
}
if r.Header.Get("If-Modified-Since") == auto.AssetsBuildDate {
w.WriteHeader(http.StatusNotModified)
return
}
mtype := mimeTypeForFile(path)
if len(mtype) != 0 {
w.Header().Set("Content-Type", mtype)
@ -214,8 +209,6 @@ func handleAssets(w http.ResponseWriter, r *http.Request) {
gr.Close()
}
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(bs)))
w.Header().Set("Last-Modified", auto.AssetsBuildDate)
w.Header().Set("Cache-Control", "public")
w.Write(bs)
}