]> Cypherpunks.ru repositories - gocheese.git/blobdiff - refresh.go
io/ioutil is deprecated since Go 1.16
[gocheese.git] / refresh.go
index 607ef4c50281bea7d5e9fd8bd114a92a1dd056fa..ea3af19c049d4738273a63f9189267577914e5f7 100644 (file)
@@ -28,7 +28,6 @@ import (
        "errors"
        "hash"
        "io"
-       "io/ioutil"
        "log"
        "net/http"
        "net/url"
@@ -115,7 +114,7 @@ func refreshDir(
                        http.Error(w, "PyPI has non 200 status code", http.StatusBadGateway)
                        return false
                }
-               body, err := ioutil.ReadAll(resp.Body)
+               body, err := io.ReadAll(resp.Body)
                if err != nil {
                        resp.Body.Close()
                        log.Println("error", r.RemoteAddr, "refresh-json", pkgName, err)
@@ -240,7 +239,7 @@ func refreshDir(
                        return false
                }
                path := filepath.Join(dirPath, MDFile)
-               existing, err := ioutil.ReadFile(path)
+               existing, err := os.ReadFile(path)
                if err != nil || bytes.Compare(existing, buf.Bytes()) != 0 {
                        if err = WriteFileSync(dirPath, path, buf.Bytes(), now); err != nil {
                                log.Println("error", r.RemoteAddr, "refresh-json", path, err)
@@ -284,7 +283,7 @@ func refreshDir(
                http.Error(w, "PyPI has non 200 status code", http.StatusBadGateway)
                return false
        }
-       body, err := ioutil.ReadAll(resp.Body)
+       body, err := io.ReadAll(resp.Body)
        resp.Body.Close()
        if err != nil {
                log.Println("error", r.RemoteAddr, "refresh", pkgName, err)
@@ -434,7 +433,7 @@ func refreshDir(
                                http.Error(w, "digest mismatch", http.StatusBadGateway)
                                return false
                        }
-                       if digestStored, err := ioutil.ReadFile(path + "." + hashAlgo); err == nil &&
+                       if digestStored, err := os.ReadFile(path + "." + hashAlgo); err == nil &&
                                bytes.Compare(digest, digestStored) != 0 {
                                err = errors.New("stored digest mismatch")
                                log.Println("error", r.RemoteAddr, "pypi", filename, err)
@@ -531,7 +530,7 @@ func refreshDir(
                                resp.Body.Close()
                                goto GPGSigSkip
                        }
-                       sig, err := ioutil.ReadAll(resp.Body)
+                       sig, err := io.ReadAll(resp.Body)
                        resp.Body.Close()
                        if err != nil {
                                goto GPGSigSkip