Skip to content

Commit d9b26fc

Browse files
committed
fix: only store regular files in tar
1 parent 1b9e0fd commit d9b26fc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,14 @@ func addFileToTar(tw *tar.Writer, path string, pathInArchive string) error {
433433
if err := tw.WriteHeader(header); err != nil {
434434
return err
435435
}
436-
// copy the file data to the tarball
437-
if _, err := io.Copy(tw, file); err != nil {
438-
return err
436+
437+
// Check for regular files
438+
if header.Typeflag == tar.TypeReg {
439+
// copy the file data to the tarball
440+
_, err := io.Copy(tw, file)
441+
if err != nil {
442+
return fmt.Errorf("%s: copying contents: %w", file.Name(), err)
443+
}
439444
}
440445
}
441446
return nil

0 commit comments

Comments
 (0)