Replaced log.Fatal() with fmt.Println() and return for non-critical functions
This commit is contained in:
parent
6a532e5511
commit
9087cf6b4d
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "0.36.1"
|
var Version = "0.36.2"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(versionCmd)
|
rootCmd.AddCommand(versionCmd)
|
||||||
|
|
31
cmd/web.go
31
cmd/web.go
|
@ -10,7 +10,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -258,9 +257,7 @@ func refreshInterval(r *http.Request, Regexes *Regexes) (int64, string) {
|
||||||
return 0, "0ms"
|
return 0, "0ms"
|
||||||
}
|
}
|
||||||
|
|
||||||
durationInMs := duration.Milliseconds()
|
return duration.Milliseconds(), refreshInterval
|
||||||
|
|
||||||
return durationInMs, refreshInterval
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortOrder(r *http.Request) string {
|
func sortOrder(r *http.Request) string {
|
||||||
|
@ -511,7 +508,8 @@ func serveStatsHandler(args []string, stats *ServeStats) http.HandlerFunc {
|
||||||
|
|
||||||
response, err := stats.ListImages()
|
response, err := stats.ListImages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write(response)
|
w.Write(response)
|
||||||
|
@ -531,7 +529,7 @@ func serveStaticFileHandler(paths []string, stats *ServeStats) http.HandlerFunc
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
err := serveStaticFile(w, r, paths, stats)
|
err := serveStaticFile(w, r, paths, stats)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -540,7 +538,8 @@ func serveHtmlHandler(paths []string, Regexes *Regexes, index *Index) http.Handl
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
refererUri, err := stripQueryParams(refererToUri(r.Referer()))
|
refererUri, err := stripQueryParams(refererToUri(r.Referer()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
filters := &Filters{
|
filters := &Filters{
|
||||||
|
@ -559,7 +558,8 @@ func serveHtmlHandler(paths []string, Regexes *Regexes, index *Index) http.Handl
|
||||||
if refererUri != "" {
|
if refererUri != "" {
|
||||||
filePath, err = nextFile(refererUri, sortOrder, Regexes)
|
filePath, err = nextFile(refererUri, sortOrder, Regexes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,8 @@ func serveHtmlHandler(paths []string, Regexes *Regexes, index *Index) http.Handl
|
||||||
|
|
||||||
return
|
return
|
||||||
case err != nil:
|
case err != nil:
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,7 +593,8 @@ func serveHtmlHandler(paths []string, Regexes *Regexes, index *Index) http.Handl
|
||||||
|
|
||||||
exists, err := fileExists(filePath)
|
exists, err := fileExists(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if !exists {
|
if !exists {
|
||||||
notFound(w, r, filePath)
|
notFound(w, r, filePath)
|
||||||
|
@ -602,7 +604,8 @@ func serveHtmlHandler(paths []string, Regexes *Regexes, index *Index) http.Handl
|
||||||
|
|
||||||
image, err := isImage(filePath)
|
image, err := isImage(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if !image {
|
if !image {
|
||||||
notFound(w, r, filePath)
|
notFound(w, r, filePath)
|
||||||
|
@ -612,12 +615,14 @@ func serveHtmlHandler(paths []string, Regexes *Regexes, index *Index) http.Handl
|
||||||
|
|
||||||
dimensions, err := imageDimensions(filePath)
|
dimensions, err := imageDimensions(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = serveHtml(w, r, filePath, dimensions, filters, Regexes)
|
err = serveHtml(w, r, filePath, dimensions, filters, Regexes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue