diff --git a/cmd/version.go b/cmd/version.go index 3026607..4278d43 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.29.0" +var Version = "0.29.1" func init() { rootCmd.AddCommand(versionCmd) diff --git a/cmd/web.go b/cmd/web.go index 93428a0..8fe2911 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -59,6 +59,14 @@ func (f *Filters) GetExcludes() string { return strings.Join(f.Excludes, ",") } +func generateCache(args []string, fileCache *[]string) error { + filters := &Filters{} + fmt.Printf("%v | Preparing image cache...\n", time.Now().Format(LogDate)) + _, err := pickFile(args, filters, "", fileCache) + + return err +} + func notFound(w http.ResponseWriter, r *http.Request, filePath string) error { startTime := time.Now() @@ -443,6 +451,13 @@ func ServePage(args []string) error { fileCache := &[]string{} + if Cache { + err := generateCache(args, fileCache) + if err != nil { + return err + } + } + http.Handle("/", serveHtmlHandler(paths, regexes, fileCache)) http.Handle(Prefix+"/", http.StripPrefix(Prefix, serveStaticFileHandler(paths))) http.HandleFunc("/favicon.ico", doNothing)