From d2368884b7bc3ae04c4a9e3fb51fd8bcd1739235 Mon Sep 17 00:00:00 2001 From: Seednode Date: Sat, 3 Jun 2023 18:45:32 -0500 Subject: [PATCH] Formatting cleanup for return values --- cmd/files.go | 2 ++ cmd/web.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/cmd/files.go b/cmd/files.go index ee207a8..9c3fdc1 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -460,6 +460,7 @@ func scanPath(path string, files *Files, filters *Filters, stats *ScanStats, con go func() { defer func() { <-concurrency.fileScans + wg.Done() }() @@ -523,6 +524,7 @@ func fileList(paths []string, filters *Filters, sort string, index *Index) ([]st go func(i int) { defer func() { <-concurrency.directoryScans + wg.Done() }() diff --git a/cmd/web.go b/cmd/web.go index 7c54003..2ad9126 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -325,6 +325,7 @@ func (s *ServeStats) GetMostServed() string { for _, v := range stats.List { if retVal == "" { retVal = v + continue } @@ -603,7 +604,9 @@ func serveCacheClear(args []string, index *Index) httprouter.Handle { index.generateCache(args) w.WriteHeader(http.StatusOK) + w.Header().Set("Content-Type", "text/plain") + w.Write([]byte("Ok")) } } @@ -629,6 +632,7 @@ func serveStats(args []string, stats *ServeStats) httprouter.Handle { response, err := stats.ListImages() if err != nil { fmt.Println(err) + return } @@ -735,12 +739,14 @@ func serveStaticFile(paths []string, stats *ServeStats) httprouter.Handle { prefixedFilePath, err := stripQueryParams(path) if err != nil { fmt.Println(err) + return } filePath, err := filepath.EvalSymlinks(strings.TrimPrefix(prefixedFilePath, SourcePrefix)) if err != nil { fmt.Println(err) + return } @@ -753,6 +759,7 @@ func serveStaticFile(paths []string, stats *ServeStats) httprouter.Handle { exists, err := fileExists(filePath) if err != nil { fmt.Println(err) + return } @@ -767,6 +774,7 @@ func serveStaticFile(paths []string, stats *ServeStats) httprouter.Handle { buf, err := os.ReadFile(filePath) if err != nil { fmt.Println(err) + return }