Fix capitalization of Serve->SERVE, fix double cache export

This commit is contained in:
Seednode 2023-09-27 19:01:18 -05:00
parent 1b84606232
commit c11ddae546
3 changed files with 11 additions and 5 deletions

View File

@ -72,6 +72,12 @@ func (cache *fileCache) set(val []string) {
} }
} }
func (cache *fileCache) clear() {
cache.mutex.Lock()
cache.list = nil
cache.mutex.Unlock()
}
func (cache *fileCache) isEmpty() bool { func (cache *fileCache) isEmpty() bool {
cache.mutex.RLock() cache.mutex.RLock()
length := len(cache.list) length := len(cache.list)
@ -152,15 +158,15 @@ func (cache *fileCache) Import(path string) error {
func serveCacheClear(args []string, cache *fileCache, formats *types.Types, errorChannel chan<- error) httprouter.Handle { func serveCacheClear(args []string, cache *fileCache, formats *types.Types, errorChannel chan<- error) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
list, err := fileList(args, &filters{}, "", &fileCache{}, formats) cache.clear()
_, err := fileList(args, &filters{}, "", cache, formats)
if err != nil { if err != nil {
errorChannel <- err errorChannel <- err
return return
} }
cache.set(list)
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain")
w.Write([]byte("Ok")) w.Write([]byte("Ok"))

View File

@ -123,7 +123,7 @@ func serveIndexHtml(args []string, cache *fileCache, paginate bool) httprouter.H
} }
if Verbose { if Verbose {
fmt.Printf("%s | Serve: HTML index page (%s) to %s in %s\n", fmt.Printf("%s | SERVE: HTML index page (%s) to %s in %s\n",
startTime.Format(logDate), startTime.Format(logDate),
humanReadableSize(b), humanReadableSize(b),
realIP(r), realIP(r),

View File

@ -12,7 +12,7 @@ import (
) )
const ( const (
ReleaseVersion string = "0.96.3" ReleaseVersion string = "0.96.4"
) )
var ( var (