Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,18 @@ func createTar(srcDir, destPath string) error {
return nil
}

f, err := os.Open(path)
if err != nil {
return err
}
defer closeWithLog(f, "file")
return copyFileToTar(tw, path)
})
}

_, err = io.Copy(tw, f)
// copyFileToTar copies a single file to a tar writer, ensuring the file is closed immediately after copying
func copyFileToTar(tw *tar.Writer, path string) error {
f, err := os.Open(path)
if err != nil {
return err
})
}
defer closeWithLog(f, "file")

_, err = io.Copy(tw, f)
return err
}