Remove file from filesystem and cache at same time during serveStaticFile()
This commit is contained in:
parent
26475ed491
commit
53d14ff279
|
@ -17,7 +17,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version string = "0.59.1"
|
Version string = "0.59.2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
12
cmd/web.go
12
cmd/web.go
|
@ -780,7 +780,7 @@ func serveDebugJson(args []string, index *Index) httprouter.Handle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func serveStaticFile(paths []string, stats *ServeStats) httprouter.Handle {
|
func serveStaticFile(paths []string, stats *ServeStats, index *Index) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
path := strings.TrimPrefix(r.URL.Path, SourcePrefix)
|
path := strings.TrimPrefix(r.URL.Path, SourcePrefix)
|
||||||
|
|
||||||
|
@ -839,6 +839,10 @@ func serveStaticFile(paths []string, stats *ServeStats) httprouter.Handle {
|
||||||
fileSize := humanReadableSize(len(buf))
|
fileSize := humanReadableSize(len(buf))
|
||||||
|
|
||||||
if russian {
|
if russian {
|
||||||
|
if cache {
|
||||||
|
index.Remove(filePath)
|
||||||
|
}
|
||||||
|
|
||||||
err = os.Remove(filePath)
|
err = os.Remove(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -1037,10 +1041,6 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if russian && cache {
|
|
||||||
index.Remove(filePath)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1142,7 +1142,7 @@ func ServePage(args []string) error {
|
||||||
|
|
||||||
mux.GET(ImagePrefix+"/*image", serveImage(paths, Regexes, index))
|
mux.GET(ImagePrefix+"/*image", serveImage(paths, Regexes, index))
|
||||||
|
|
||||||
mux.GET(SourcePrefix+"/*static", serveStaticFile(paths, stats))
|
mux.GET(SourcePrefix+"/*static", serveStaticFile(paths, stats, index))
|
||||||
|
|
||||||
mux.GET("/version", serveVersion())
|
mux.GET("/version", serveVersion())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue