From 18daa3feff47691b03f2af3cefa47b53ad7a1dc3 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Tue, 4 Mar 2025 15:52:59 +0100 Subject: [PATCH] clean up --- libs/patchwheel/patch.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libs/patchwheel/patch.go b/libs/patchwheel/patch.go index a7a8bd500..5806c860a 100644 --- a/libs/patchwheel/patch.go +++ b/libs/patchwheel/patch.go @@ -11,6 +11,7 @@ import ( "fmt" "io" "os" + "path" "path/filepath" "strconv" "strings" @@ -27,13 +28,10 @@ const ( func readMetadataAndRecord(r *zip.ReadCloser) (metadataFile, recordFile *zip.File, oldDistInfoPrefix string) { for _, f := range r.File { if metadataFile == nil { - matched, _ := filepath.Match("*.dist-info/METADATA", f.Name) + matched, _ := path.Match("*.dist-info/METADATA", f.Name) if matched { metadataFile = f - // Determine the old dist-info directory prefix. - if i := strings.LastIndex(f.Name, "/"); i != -1 { - oldDistInfoPrefix = f.Name[:i+1] - } + oldDistInfoPrefix = path.Dir(f.Name) + "/" if recordFile != nil { break @@ -44,7 +42,7 @@ func readMetadataAndRecord(r *zip.ReadCloser) (metadataFile, recordFile *zip.Fil } if recordFile == nil { - matched, _ := filepath.Match("*.dist-info/RECORD", f.Name) + matched, _ := path.Match("*.dist-info/RECORD", f.Name) if matched { recordFile = f