X-Git-Url: http://www.git.cypherpunks.ru/?p=gocheese.git;a=blobdiff_plain;f=gocheese.go;h=5ecd959bc61e6f1a5881f8dc0d6b8c6b97b43de6;hp=75a7c1caf120a5b83803f6a099bc8625032d64d7;hb=5d0340e435f90599a8072ad8cd67ef8ef4be116a;hpb=7463a4bbcd0ace5790125f2d3f01eb48abaca985 diff --git a/gocheese.go b/gocheese.go index 75a7c1c..5ecd959 100644 --- a/gocheese.go +++ b/gocheese.go @@ -208,20 +208,29 @@ func refreshDir( } } if filename == filenameGet || gpgUpdate { - if _, err = os.Stat(path); err == nil { - if resp, err := http.Get(pkgURL.String() + GPGSigExt); err == nil { - sig, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() - if err == nil { - if err = WriteFileSync(dirPath, path+GPGSigExt, sig); err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return false - } - log.Println(r.RemoteAddr, "pypi downloaded signature", filename) - } - } + if _, err = os.Stat(path); err != nil { + goto GPGSigSkip + } + resp, err := http.Get(pkgURL.String() + GPGSigExt) + if err != nil { + goto GPGSigSkip + } + if resp.StatusCode != http.StatusOK { + resp.Body.Close() + goto GPGSigSkip + } + sig, err := ioutil.ReadAll(resp.Body) + resp.Body.Close() + if err != nil { + goto GPGSigSkip + } + if err = WriteFileSync(dirPath, path+GPGSigExt, sig); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return false } + log.Println(r.RemoteAddr, "pypi downloaded signature", filename) } + GPGSigSkip: path = path + SHA256Ext _, err = os.Stat(path) if err == nil {