X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=gocheese.go;h=5c6e80a2fc172d81d676e77f1199c3d3cb90dcc0;hb=443748e27be6e25fb36b1d32d4aee1a3da1b5539;hp=02aa225f252bbbd2461b298b6f59be5d9b942f9e;hpb=ad6b9b1dca039678e7c48fe07e864b614e01158f;p=gocheese.git diff --git a/gocheese.go b/gocheese.go index 02aa225..5c6e80a 100644 --- a/gocheese.go +++ b/gocheese.go @@ -107,8 +107,8 @@ func refreshDir(w http.ResponseWriter, r *http.Request, dir, filenameGet string) http.Error(w, err.Error(), http.StatusBadGateway) return false } - defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) + resp.Body.Close() if err != nil { http.Error(w, err.Error(), http.StatusBadGateway) return false @@ -183,11 +183,10 @@ func refreshDir(w http.ResponseWriter, r *http.Request, dir, filenameGet string) _, err = os.Stat(path) if err == nil { continue - } else { - if !os.IsNotExist(err) { - http.Error(w, err.Error(), http.StatusInternalServerError) - return false - } + } + if !os.IsNotExist(err) { + http.Error(w, err.Error(), http.StatusInternalServerError) + return false } log.Println(r.RemoteAddr, "pypi touch", filename) if err = ioutil.WriteFile(path, digest, os.FileMode(0666)); err != nil { @@ -250,7 +249,7 @@ func listDir(w http.ResponseWriter, r *http.Request, dir string, autorefresh boo HTMLElement, strings.Join([]string{ *refreshURLPath, dir, "/", - filenameClean, "#", SHA256Prefix, string(data), + filenameClean, "#", SHA256Prefix, hex.EncodeToString(data), }, ""), filenameClean, )))