diff --git a/http/download.go b/http/download.go index 26431d92..a1a1d08e 100644 --- a/http/download.go +++ b/http/download.go @@ -79,11 +79,10 @@ func downloadHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int func downloadFileHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) { file, err := os.Open(c.File.Path) - defer file.Close() - if err != nil { return http.StatusInternalServerError, err } + defer file.Close() stat, err := file.Stat() if err != nil { diff --git a/http/subtitle.go b/http/subtitle.go index be54cd55..e83f295b 100644 --- a/http/subtitle.go +++ b/http/subtitle.go @@ -2,12 +2,13 @@ package http import ( "bytes" - fb "github.com/filebrowser/filebrowser" "io/ioutil" "net/http" "os" "path/filepath" "regexp" + + fb "github.com/filebrowser/filebrowser" ) func subtitlesHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) { @@ -36,11 +37,10 @@ func subtitleHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int } file, err := os.Open(c.File.Path) - defer file.Close() - if err != nil { return http.StatusInternalServerError, err } + defer file.Close() stat, err := file.Stat() if err != nil { diff --git a/staticgen/hugo.go b/staticgen/hugo.go index 284e46e7..d9e989a6 100644 --- a/staticgen/hugo.go +++ b/staticgen/hugo.go @@ -187,9 +187,6 @@ func (h Hugo) undraft(file string) error { // Setup sets up the plugin. func (h *Hugo) Setup() error { var err error - if h.Exe, err = exec.LookPath("hugo"); err != nil { - return err - } - - return nil + h.Exe, err = exec.LookPath("hugo") + return err }