Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add zip file func to simplify working with gzip encoding #19

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

jsteenb2
Copy link
Collaborator

This also changes the File.Contents to a ReadCloser type. After more experimenting with this, we really want to be able to support the closing behavior.

@jsteenb2 jsteenb2 requested a review from johns31459 June 13, 2024 23:29
file.go Outdated
}

// FileGZip writes the
func FileGZip(filename, contentType string, contents io.ReadCloser) File {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh this will probably be the first thing I use writing my next fn... just too easy to pass up 🙃


wantFilename := filepath.Join(tmp, "third_file.json")
equalVals(t, wantFilename, got.Filename)
equalGzipFiles(t, got.Filename, `{"dodgers":"reallystank"}`)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:yesssssss:

func (c *compressorGZIP) compressInput() {
defer func() {
c.gwClosed, c.pwClosed = true, true
err := c.pw.CloseWithError(c.gw.Close())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order of operations here is very important, gzip writer has to close first, or it isn't able to write the final bits it writes on Close, rendering the entire gzip defunct

@jsteenb2 jsteenb2 force-pushed the feat/add_gzip_file branch 2 times, most recently from e57c4f7 to bcab699 Compare June 14, 2024 06:20
@jsteenb2 jsteenb2 force-pushed the feat/add_gzip_file branch from bcab699 to 3841319 Compare June 14, 2024 07:51
@jsteenb2 jsteenb2 merged commit 9fe315d into main Jun 14, 2024
1 check passed
@jsteenb2 jsteenb2 deleted the feat/add_gzip_file branch June 14, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants