]> Cypherpunks.ru repositories - gocheese.git/blobdiff - list.go
More convenient trusted-host
[gocheese.git] / list.go
diff --git a/list.go b/list.go
index 356cd6bf01874f5aaf687028d3dfd556dc56db76..779e348353b6e6638799933eaaaca47d092e3d4f 100644 (file)
--- a/list.go
+++ b/list.go
@@ -1,19 +1,17 @@
-/*
-GoCheese -- Python private package repository and caching proxy
-Copyright (C) 2019-2022 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
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
+// GoCheese -- Python private package repository and caching proxy
+// Copyright (C) 2019-2024 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
+// the Free Software Foundation, version 3 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 package main
 
@@ -25,7 +23,6 @@ import (
        "fmt"
        "html/template"
        "io/fs"
-       "io/ioutil"
        "log"
        "net/http"
        "os"
@@ -50,7 +47,7 @@ var (
 )
 
 func listRoot(w http.ResponseWriter, r *http.Request) {
-       files, err := ioutil.ReadDir(Root)
+       files, err := os.ReadDir(Root)
        if err != nil {
                log.Println("error", r.RemoteAddr, "root", err)
                http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -97,7 +94,6 @@ func (a PkgReleaseInfoByName) Less(i, j int) bool {
 // Version format is too complicated: https://www.python.org/dev/peps/pep-0386/
 // So here is very simple parser working good enough for most packages
 func filenameToVersion(fn string) string {
-       fn = strings.TrimSuffix(fn, GPGSigExt)
        var trimmed string
        for _, ext := range KnownExts {
                trimmed = strings.TrimSuffix(fn, ext)
@@ -147,7 +143,7 @@ func listDir(pkgName string, doSize bool) (int64, []*PkgReleaseInfo, error) {
                                continue
                        }
                        delete(files, fn)
-                       digest, err := ioutil.ReadFile(filepath.Join(dirPath, fn))
+                       digest, err := os.ReadFile(filepath.Join(dirPath, fn))
                        if err != nil {
                                return 0, nil, err
                        }
@@ -177,10 +173,6 @@ func listDir(pkgName string, doSize bool) (int64, []*PkgReleaseInfo, error) {
                                        }
                                        delete(files, fnClean)
                                }
-                               if _, exists := files[fnClean+GPGSigExt]; exists {
-                                       release.HasSig = true
-                                       delete(files, fnClean+GPGSigExt)
-                               }
                        }
                        release.Digests[algo] = hex.EncodeToString(digest)
                }
@@ -205,15 +197,15 @@ func serveListDir(
        w http.ResponseWriter,
        r *http.Request,
        pkgName string,
-       autorefresh, gpgUpdate bool,
+       autorefresh bool,
 ) {
        dirPath := filepath.Join(Root, pkgName)
        if autorefresh {
-               if !refreshDir(w, r, pkgName, "", gpgUpdate) {
+               if !refreshDir(w, r, pkgName, "") {
                        return
                }
        } else if _, err := os.Stat(dirPath); os.IsNotExist(err) &&
-               !refreshDir(w, r, pkgName, "", false) {
+               !refreshDir(w, r, pkgName, "") {
                return
        }
        serial, releases, err := listDir(pkgName, false)