Skip to content

Commit 85fc41c

Browse files
committed
🩹 Use filepath.Base instead of path.Base
path.Base only works with '/' while 'filepath.Glob' returns path with '\' on windows
1 parent c7539c8 commit 85fc41c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

release.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"fmt"
55
"os"
6-
"path"
6+
"path/filepath"
77

88
"code.gitea.io/sdk/gitea"
99
)
@@ -86,12 +86,12 @@ func (rc *releaseClient) uploadFiles(releaseID int64, files []string) error {
8686
files:
8787
for _, file := range files {
8888
for _, attachment := range attachments {
89-
if attachment.Name == path.Base(file) {
89+
if attachment.Name == filepath.Base(file) {
9090
switch rc.FileExists {
9191
case "overwrite":
9292
// do nothing
9393
case "fail":
94-
return fmt.Errorf("Asset file %s already exists", path.Base(file))
94+
return fmt.Errorf("Asset file %s already exists", filepath.Base(file))
9595
case "skip":
9696
fmt.Printf("Skipping pre-existing %s artifact\n", attachment.Name)
9797
continue files
@@ -112,7 +112,7 @@ files:
112112
}
113113

114114
for _, attachment := range attachments {
115-
if attachment.Name == path.Base(file) {
115+
if attachment.Name == filepath.Base(file) {
116116
if _, err := rc.Client.DeleteReleaseAttachment(rc.Owner, rc.Repo, releaseID, attachment.ID); err != nil {
117117
return fmt.Errorf("Failed to delete %s artifact: %s", file, err)
118118
}
@@ -121,7 +121,7 @@ files:
121121
}
122122
}
123123

124-
if _, _, err = rc.Client.CreateReleaseAttachment(rc.Owner, rc.Repo, releaseID, handle, path.Base(file)); err != nil {
124+
if _, _, err = rc.Client.CreateReleaseAttachment(rc.Owner, rc.Repo, releaseID, handle, filepath.Base(file)); err != nil {
125125
return fmt.Errorf("Failed to upload %s artifact: %s", file, err)
126126
}
127127

utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"hash/crc32"
1111
"io"
1212
"os"
13+
"path/filepath"
1314
"strconv"
1415

1516
"golang.org/x/crypto/blake2b"
@@ -70,7 +71,7 @@ func writeChecksums(files, methods []string) ([]string, error) {
7071
return nil, err
7172
}
7273

73-
checksums[method] = append(checksums[method], hash, file)
74+
checksums[method] = append(checksums[method], hash, filepath.Base(file))
7475
}
7576
}
7677

0 commit comments

Comments
 (0)