]> Cypherpunks.ru repositories - gocheese.git/blobdiff - refresh.go
Raise copyright years
[gocheese.git] / refresh.go
index 625f840b5f3115b99b558f838f5d8953eddbc4be..11c3ab7a52a73db2c3b13aa08a0f4723c7cfbc8a 100644 (file)
@@ -1,6 +1,6 @@
 /*
 GoCheese -- Python private package repository and caching proxy
-Copyright (C) 2019-2020 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2019-2021 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -60,6 +60,12 @@ func refreshDir(
                http.Error(w, err.Error(), http.StatusBadGateway)
                return false
        }
+       if resp.StatusCode != http.StatusOK {
+               resp.Body.Close()
+               log.Println("error", r.RemoteAddr, "refresh", pkgName, "HTTP status:", resp.Status)
+               http.Error(w, "PyPI has non 200 status code", http.StatusBadGateway)
+               return false
+       }
        body, err := ioutil.ReadAll(resp.Body)
        resp.Body.Close()
        if err != nil {
@@ -154,6 +160,15 @@ func refreshDir(
                                return false
                        }
                        defer resp.Body.Close()
+                       if resp.StatusCode != http.StatusOK {
+                               log.Println(
+                                       "error", r.RemoteAddr,
+                                       "pypi", filename, "download",
+                                       "HTTP status:", resp.Status,
+                               )
+                               http.Error(w, "PyPI has non 200 status code", http.StatusBadGateway)
+                               return false
+                       }
                        hasher := hasherNew()
                        hasherSHA256 := sha256.New()
                        dst, err := TempFile(dirPath)