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

[RFC] expose Tar processing internals #69

Open
vbatts opened this issue Aug 12, 2016 · 1 comment
Open

[RFC] expose Tar processing internals #69

vbatts opened this issue Aug 12, 2016 · 1 comment

Comments

@vbatts
Copy link
Owner

vbatts commented Aug 12, 2016

Rather than having only mtree.NewTarStreamer() with returning an io.Reader.
This currently requires either a goroutine, or a struct that keeps track of position and a buffered reader. (I opted for the goroutine)

Potentially we could have an internal model of collecting the mtree entries from tar headers. Something like:

  fh, _ := os.Open("file.tar")
  //...
  dh := mtree.DirectoryHierarchy{}
  entryRdr := mtree.TarEntryReader(fh)
  for {
    e, err := entryRdr.Next()
    if err != nil {
      break
    }
    dh.Entries = append(dh.Entries, e)
  }

Then the current signature could just wrap this in a goroutine:

func NewTarStreamer(r io.Reader, keywords []string) Streamer

And then we could more easily expose a non-goroutine, but more blocking, signature like:

func NewDhFromTar(r io.Reader, keywords []string) (*DirectoryHierarchy, error)
@vbatts
Copy link
Owner Author

vbatts commented Aug 12, 2016

/cc @cyphar

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

No branches or pull requests

1 participant