Skip to content

Commit

Permalink
fix: add dir headers to zip files
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Apr 13, 2023
1 parent ec7c15d commit 4a98220
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/archive/zip/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func Copying(source *os.File, target io.Writer) (Archive, error) {
}
w := New(target)
for _, zf := range r.File {
if zf.Mode().IsDir() {
continue
}

w.files[zf.Name] = true
hdr := zip.FileHeader{
Name: zf.Name,
Expand All @@ -59,6 +57,9 @@ func Copying(source *os.File, target io.Writer) (Archive, error) {
if err != nil {
return Archive{}, fmt.Errorf("creating %q header in target: %w", zf.Name, err)
}
if zf.Mode().IsDir() {
continue
}
rr, err := zf.Open()
if err != nil {
return Archive{}, fmt.Errorf("opening %q from source: %w", zf.Name, err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/archive/zip/zip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,5 @@ func TestTarInvalidLink(t *testing.T) {
Destination: "badlink.txt",
}))
}

// TODO: add copying test

0 comments on commit 4a98220

Please sign in to comment.