Skip to content

[RFC] expose Tar processing internals #69

@vbatts

Description

@vbatts

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions