remove cache, it's not useful in practice

This commit is contained in:
Mikaël Cluseau
2025-07-01 22:20:58 +02:00
parent 5c91736202
commit 9ad7715a29
5 changed files with 20 additions and 101 deletions

View File

@ -10,6 +10,7 @@ import (
"log"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
"text/template"
@ -35,12 +36,7 @@ type renderContext struct {
}
func renderCtx(w http.ResponseWriter, r *http.Request, ctx *renderContext, what string,
create func(out io.Writer, ctx *renderContext) error) error {
tag, err := ctx.Tag()
if err != nil {
return err
}
create func(out io.Writer, ctx *renderContext) error) (err error) {
ctx.CmdLine = r.URL.Query().Get(cmdlineParam.Data().Name)
@ -49,19 +45,26 @@ func renderCtx(w http.ResponseWriter, r *http.Request, ctx *renderContext, what
}
// get it or create it
content, meta, err := casStore.GetOrCreate(tag, what, func(out io.Writer) error {
log.Printf("building %s for %q", what, ctx.Host.Name)
return create(out, ctx)
})
outfile, err := os.CreateTemp("/tmp", "dls."+what+".")
if err != nil {
return err
return
}
defer os.Remove(outfile.Name())
log.Printf("building %s for %q", what, ctx.Host.Name)
err = create(outfile, ctx)
if err != nil {
return
}
// serve it
log.Printf("sending %s for %q", what, ctx.Host.Name)
http.ServeContent(w, r, what, meta.ModTime(), content)
return nil
outfile.Seek(0, io.SeekStart)
io.Copy(w, outfile)
return
}
func sslConfigFromLocalConfig(cfg *localconfig.Config) (sslCfg *cfsslconfig.Config, err error) {