This commit is contained in:
Denis Bilenko 2025-03-04 15:52:59 +01:00
parent 9f9f89078e
commit 18daa3feff
1 changed files with 4 additions and 6 deletions

View File

@ -11,6 +11,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
@ -27,13 +28,10 @@ const (
func readMetadataAndRecord(r *zip.ReadCloser) (metadataFile, recordFile *zip.File, oldDistInfoPrefix string) { func readMetadataAndRecord(r *zip.ReadCloser) (metadataFile, recordFile *zip.File, oldDistInfoPrefix string) {
for _, f := range r.File { for _, f := range r.File {
if metadataFile == nil { if metadataFile == nil {
matched, _ := filepath.Match("*.dist-info/METADATA", f.Name) matched, _ := path.Match("*.dist-info/METADATA", f.Name)
if matched { if matched {
metadataFile = f metadataFile = f
// Determine the old dist-info directory prefix. oldDistInfoPrefix = path.Dir(f.Name) + "/"
if i := strings.LastIndex(f.Name, "/"); i != -1 {
oldDistInfoPrefix = f.Name[:i+1]
}
if recordFile != nil { if recordFile != nil {
break break
@ -44,7 +42,7 @@ func readMetadataAndRecord(r *zip.ReadCloser) (metadataFile, recordFile *zip.Fil
} }
if recordFile == nil { if recordFile == nil {
matched, _ := filepath.Match("*.dist-info/RECORD", f.Name) matched, _ := path.Match("*.dist-info/RECORD", f.Name)
if matched { if matched {
recordFile = f recordFile = f