diff --git a/cmd/files.go b/cmd/files.go index 86262f9..26675e0 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -517,39 +517,33 @@ func prepareDirectory(directory []string) []string { last = cleanFilename(last) if first == last { - return append([]string{}, directory[0]) + return []string{directory[0]} } else { return directory } } func prepareDirectories(files *Files, sort string) []string { - i, l := 0, 0 - - files.mutex.RLock() + directories := []string{} keys := make([]string, len(files.list)) + i := 0 for k := range files.list { keys[i] = k i++ - l += len(files.list[k]) } - directories := make([]string, l) - if sort == "asc" || sort == "desc" { for i := 0; i < len(keys); i++ { - copy(directories, prepareDirectory(files.list[keys[i]])) + directories = append(directories, prepareDirectory(files.list[keys[i]])...) } } else { for i := 0; i < len(keys); i++ { - copy(directories, files.list[keys[i]]) + directories = append(directories, files.list[keys[i]]...) } } - files.mutex.RUnlock() - return directories } diff --git a/cmd/version.go b/cmd/version.go index e21f671..0536d0b 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.38.1" +var Version = "0.38.2" func init() { rootCmd.AddCommand(versionCmd) diff --git a/cmd/web.go b/cmd/web.go index fcf1088..d003691 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -35,9 +35,10 @@ var ( ) const ( - LogDate string = `2006-01-02T15:04:05.000-07:00` - Prefix string = `/src` - RedirectStatusCode int = http.StatusSeeOther + LogDate string = `2006-01-02T15:04:05.000-07:00` + Prefix string = `/src` + RedirectStatusCode int = http.StatusSeeOther + Timeout time.Duration = 10 * time.Second ) type Regexes struct { @@ -682,7 +683,18 @@ func serveHtmlHandler(paths []string, Regexes *Regexes, index *Index) http.Handl } } - if filePath == "" { + loop: + for timeout := time.After(Timeout); ; { + select { + case <-timeout: + break loop + default: + } + + if filePath != "" { + break loop + } + filePath, err = newFile(paths, filters, sortOrder, Regexes, index) switch { case err != nil && err == ErrNoImagesFound: diff --git a/stats.file b/stats.file deleted file mode 100644 index 232038b..0000000 Binary files a/stats.file and /dev/null differ