-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
file.go
Outdated
} | ||
|
||
// FileGZip writes the | ||
func FileGZip(filename, contentType string, contents io.ReadCloser) File { |
There was a problem hiding this comment.
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"}`) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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
e57c4f7
to
bcab699
Compare
bcab699
to
3841319
Compare
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.