2 GoCheese -- Python private package repository and caching proxy
3 Copyright (C) 2019-2020 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
31 func goodIntegrity() bool {
32 dirs, err := ioutil.ReadDir(*root)
36 hasher := sha256.New()
37 digest := make([]byte, sha256.Size)
41 for _, dir := range dirs {
42 files, err := ioutil.ReadDir(filepath.Join(*root, dir.Name()))
46 for _, file := range files {
47 if !strings.HasSuffix(file.Name(), "."+HashAlgoSHA256) {
50 pkgName = strings.TrimSuffix(file.Name(), "."+HashAlgoSHA256)
51 data, err = ioutil.ReadFile(filepath.Join(*root, dir.Name(), pkgName))
53 if os.IsNotExist(err) {
59 data, err = ioutil.ReadFile(filepath.Join(*root, dir.Name(), file.Name()))
63 if bytes.Compare(hasher.Sum(digest[:0]), data) == 0 {
64 fmt.Println(pkgName, "GOOD")
67 fmt.Fprintln(os.Stderr, pkgName, "BAD")