From 538b99ee7717d5a0ae1d0fa535393730241f9b28 Mon Sep 17 00:00:00 2001 From: Equim Date: Sat, 14 Oct 2017 17:07:01 +0800 Subject: [PATCH] Don't expose error (#254) * share: remove share link when it has been moved * http: don't expose error --- http/http.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/http/http.go b/http/http.go index b2fdd40b..1aaa6a74 100644 --- a/http/http.go +++ b/http/http.go @@ -25,16 +25,13 @@ func Handler(m *fm.FileManager) http.Handler { if code >= 400 { w.WriteHeader(code) - if err == nil { - txt := http.StatusText(code) - log.Printf("%v: %v %v\n", r.URL.Path, code, txt) - w.Write([]byte(txt)) - } + txt := http.StatusText(code) + log.Printf("%v: %v %v\n", r.URL.Path, code, txt) + w.Write([]byte(txt + "\n")) } if err != nil { log.Print(err) - w.Write([]byte(err.Error())) } }) } @@ -270,6 +267,7 @@ func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, erro info, err := os.Stat(s.Path) if err != nil { + c.Store.Share.Delete(s.Hash) return ErrorToHTTP(err, false), err }