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

Close sink.GetWriter results in zipextractor #5

Closed
wants to merge 1 commit into from

Conversation

200sc
Copy link

@200sc 200sc commented Feb 20, 2018

Fixes #4

@fasterthanlime
Copy link
Collaborator

The way the savior API is currently designed, extractors should be used like so:

func something() {
  sink := makeSink()
  defer sink.Close()
  
  res, err := getExtractor().Resume(nil, sink)
  // handle err etc.
}

One could argue otherwise, but I think this follows a pattern often found in Go libraries: if you open a file, you're in charge of closing it - whatever you pass it to shouldn't close it for you.

Extractors should call entryWriter.Sync() when they checkpoint, to make sure the checkpoint actually corresponds to what's on disk, but they don't have the responsibility to close any writer or sink.

See: https://github.com/itchio/butler/blob/b38feca3f276c0c9aa15de94a321cbc9bdab401f/archive/simple_extract.go#L16-L48

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