Create dir every time
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 58s

This commit is contained in:
Alexandre Bruyant 2024-01-07 19:51:18 +01:00
parent 6b4eec8251
commit d9623d5615

40
main.go
View File

@ -114,34 +114,34 @@ func main() {
defer mwriter.Close()
defer writer.Close()
w, err := mwriter.CreateIpfsDirectoryPart(path)
if err != nil {
githubactions.Fatalf("Unable to create root dir path: %v", fmt.Errorf("%w", err))
}
err = filepath.Walk(path, func(innerPath string, info fs.FileInfo, err error) error {
if err != nil {
return err
}
relPath, _ := filepath.Rel(path, innerPath)
if info.IsDir() {
return nil
}
_, err = mwriter.CreateIpfsDirectoryPart(relPath)
if err != nil {
return err
}
} else {
w, err := mwriter.CreateIpfsFilePart(relPath)
if err != nil {
return err
}
w, err = mwriter.CreateIpfsFilePart(innerPath)
if err != nil {
return err
}
fileReader, err := os.Open(innerPath)
if err != nil {
return err
}
defer fileReader.Close()
fileReader, err := os.Open(innerPath)
if err != nil {
return err
}
defer fileReader.Close()
written, err := io.Copy(w, fileReader)
if err != nil {
return fmt.Errorf("error copying %s (%d bytes written): %v", innerPath, written, err)
written, err := io.Copy(w, fileReader)
if err != nil {
return fmt.Errorf("error copying %s (%d bytes written): %v", innerPath, written, err)
}
}
return nil