diff --git a/cmd/cache.go b/cmd/cache.go index c3d143a..f36f00b 100644 --- a/cmd/cache.go +++ b/cmd/cache.go @@ -181,3 +181,23 @@ func registerCacheHandlers(mux *httprouter.Router, args []string, errorChannel c return nil } + +func importCache(args []string) error { + skipIndex := false + + if CacheFile != "" { + err := cache.Import(CacheFile) + if err == nil { + skipIndex = true + } + } + + if !skipIndex { + _, err := fileList(args, &filters{}, "") + if err != nil { + return err + } + } + + return nil +} diff --git a/cmd/root.go b/cmd/root.go index f282a3c..9a0f479 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( ) const ( - ReleaseVersion string = "0.95.1" + ReleaseVersion string = "0.95.2" ) var ( diff --git a/cmd/web.go b/cmd/web.go index 0c3b4f9..77102e4 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -436,24 +436,6 @@ func ServePage(args []string) error { return ErrNoMediaFound } - skipIndex := false - - if CacheFile != "" { - err := cache.Import(CacheFile) - if err == nil { - skipIndex = true - } - } - - if !skipIndex { - _, err := fileList(args, &filters{}, "") - if err != nil { - return err - } - } - - mux := httprouter.New() - listenHost := net.JoinHostPort(Bind, strconv.Itoa(Port)) if Verbose { @@ -463,6 +445,13 @@ func ServePage(args []string) error { ) } + err = importCache(args) + if err != nil { + return err + } + + mux := httprouter.New() + srv := &http.Server{ Addr: listenHost, Handler: mux,