Directly call getFileList() when generating cache, instead of pickFile()

This commit is contained in:
Seednode 2023-01-21 16:20:35 -06:00
parent 3bf3c5b5ed
commit 66f6069d96
2 changed files with 5 additions and 15 deletions

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var Version = "0.33.1" var Version = "0.33.2"
func init() { func init() {
rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(versionCmd)

View File

@ -81,17 +81,13 @@ func (i *Index) Set(val []string) {
i.Mutex.Unlock() i.Mutex.Unlock()
} }
func (i *Index) GenerateCache(args []string) error { func (i *Index) GenerateCache(args []string) {
filters := &Filters{}
i.Mutex.Lock() i.Mutex.Lock()
i.List = []string{} i.List = []string{}
i.Mutex.Unlock() i.Mutex.Unlock()
fmt.Printf("%v | Preparing image cache...\n", time.Now().Format(LogDate)) fmt.Printf("%v | Preparing image cache...\n", time.Now().Format(LogDate))
_, err := pickFile(args, filters, "", i) getFileList(args, &Filters{}, "", i)
return err
} }
func (i *Index) IsEmpty() bool { func (i *Index) IsEmpty() bool {
@ -437,10 +433,7 @@ func serveStaticFile(w http.ResponseWriter, r *http.Request, paths []string, sta
func serveCacheClearHandler(args []string, index *Index) http.HandlerFunc { func serveCacheClearHandler(args []string, index *Index) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
err := index.GenerateCache(args) index.GenerateCache(args)
if err != nil {
fmt.Println(err)
}
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain")
@ -582,10 +575,7 @@ func ServePage(args []string) error {
} }
if Cache { if Cache {
err := index.GenerateCache(args) index.GenerateCache(args)
if err != nil {
return err
}
http.Handle("/_/clear_cache", serveCacheClearHandler(args, index)) http.Handle("/_/clear_cache", serveCacheClearHandler(args, index))
} }