Return early if walk target is dir
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 59s
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 59s
This commit is contained in:
parent
41cc0cb790
commit
2f3c0ee4e2
21
main.go
21
main.go
@ -73,15 +73,12 @@ func main() {
|
||||
|
||||
err = filepath.Walk(path, func(innerPath string, info fs.FileInfo, err error) error {
|
||||
githubactions.Infof("Reading %v", innerPath)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
relativeParh := strings.TrimPrefix(innerPath, path)
|
||||
w, err := mwriter.CreateFormFile("file", relativeParh)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
in, err := os.Open(innerPath)
|
||||
if err != nil {
|
||||
@ -89,8 +86,22 @@ func main() {
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
pathInfo, err := in.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if pathInfo.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
w, err := mwriter.CreateFormFile("file", relativeParh)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if written, err := io.Copy(w, in); err != nil {
|
||||
return fmt.Errorf("error copying %s (%d bytes written): %v", path, written, err)
|
||||
return fmt.Errorf("error copying %s (%d bytes written): %v", relativeParh, written, err)
|
||||
}
|
||||
|
||||
if err := mwriter.Close(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user