]> Cypherpunks.ru repositories - gocheese.git/blobdiff - refresh.go
chan os.Signal should be buffered
[gocheese.git] / refresh.go
index ea3af19c049d4738273a63f9189267577914e5f7..4179953179f7e703290409b69d8b6db349d9971f 100644 (file)
@@ -1,6 +1,6 @@
 /*
 GoCheese -- Python private package repository and caching proxy
-Copyright (C) 2019-2022 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2019-2023 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
@@ -240,7 +240,7 @@ func refreshDir(
                }
                path := filepath.Join(dirPath, MDFile)
                existing, err := os.ReadFile(path)
-               if err != nil || bytes.Compare(existing, buf.Bytes()) != 0 {
+               if err != nil || !bytes.Equal(existing, buf.Bytes()) {
                        if err = WriteFileSync(dirPath, path, buf.Bytes(), now); err != nil {
                                log.Println("error", r.RemoteAddr, "refresh-json", path, err)
                                http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -426,7 +426,7 @@ func refreshDir(
                                http.Error(w, err.Error(), http.StatusInternalServerError)
                                return false
                        }
-                       if bytes.Compare(hasher.Sum(nil), digest) != 0 {
+                       if !bytes.Equal(hasher.Sum(nil), digest) {
                                log.Println(r.RemoteAddr, "pypi", filename, "digest mismatch")
                                os.Remove(dst.Name())
                                dst.Close()
@@ -434,7 +434,7 @@ func refreshDir(
                                return false
                        }
                        if digestStored, err := os.ReadFile(path + "." + hashAlgo); err == nil &&
-                               bytes.Compare(digest, digestStored) != 0 {
+                               !bytes.Equal(digest, digestStored) {
                                err = errors.New("stored digest mismatch")
                                log.Println("error", r.RemoteAddr, "pypi", filename, err)
                                os.Remove(dst.Name())