X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=refresh.go;h=ea3af19c049d4738273a63f9189267577914e5f7;hb=3bbd67eb5067bf180ed260acee4a2c1a6f6db9ec;hp=48b2a744f66340aa99d81f9ded75b2a82811ed33;hpb=b667be1932f0cab6e0ba9619bad92f8ac17f884d;p=gocheese.git diff --git a/refresh.go b/refresh.go index 48b2a74..ea3af19 100644 --- a/refresh.go +++ b/refresh.go @@ -1,6 +1,6 @@ /* GoCheese -- Python private package repository and caching proxy -Copyright (C) 2019-2021 Sergey Matveev +Copyright (C) 2019-2022 Sergey Matveev 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 @@ -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