X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=integrity.go;h=3a2d4e0c073e68ed34e5061f227bd0d21216fb74;hb=3bbd67eb5067bf180ed260acee4a2c1a6f6db9ec;hp=84011fe23acafec4310d0d0892c281cdd1bd9967;hpb=db1754452806598545038fb78deae6788cae2af8;p=gocheese.git diff --git a/integrity.go b/integrity.go index 84011fe..3a2d4e0 100644 --- a/integrity.go +++ b/integrity.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 @@ -24,7 +24,6 @@ import ( "fmt" "hash" "io" - "io/ioutil" "log" "os" "path/filepath" @@ -37,7 +36,7 @@ func checkFile( pkgName, fn, fnHash, hasherName string, hasher hash.Hash, digest []byte, ) bool { - expected, err := ioutil.ReadFile(fnHash) + expected, err := os.ReadFile(fnHash) if err != nil { log.Fatal(err) } @@ -64,7 +63,7 @@ func checkFile( } func goodIntegrity() bool { - dirs, err := ioutil.ReadDir(*Root) + dirs, err := os.ReadDir(Root) if err != nil { log.Fatal(err) } @@ -75,7 +74,7 @@ func goodIntegrity() bool { isGood := true var pkgName string for _, dir := range dirs { - files, err := ioutil.ReadDir(filepath.Join(*Root, dir.Name())) + files, err := os.ReadDir(filepath.Join(Root, dir.Name())) if err != nil { log.Fatal(err) } @@ -84,8 +83,8 @@ func goodIntegrity() bool { pkgName = strings.TrimSuffix(file.Name(), "."+HashAlgoSHA256) if !checkFile( pkgName, - filepath.Join(*Root, dir.Name(), pkgName), - filepath.Join(*Root, dir.Name(), file.Name()), + filepath.Join(Root, dir.Name(), pkgName), + filepath.Join(Root, dir.Name(), file.Name()), "SHA256", hasherSHA256, digestSHA256, ) { isGood = false @@ -96,8 +95,8 @@ func goodIntegrity() bool { pkgName = strings.TrimSuffix(file.Name(), "."+HashAlgoBLAKE2b256) if !checkFile( pkgName, - filepath.Join(*Root, dir.Name(), pkgName), - filepath.Join(*Root, dir.Name(), file.Name()), + filepath.Join(Root, dir.Name(), pkgName), + filepath.Join(Root, dir.Name(), file.Name()), "BLAKE2b-256", hasherBLAKE2b256, digestBLAKE2b256, ) { isGood = false