Version: v0.6.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2016 License: MIT, Apache-2.0 Imports: 9 Imported by: 0



This library for assembly and disassembly of tar archives, facilitated by


For completely safe assembly/disassembly, there will need to be a Content Addressable Storage (CAS) directory, that maps to a checksum in the storage.Entity of storage.FileType.

This is due to the fact that tar archives can allow multiple records for the same path, but the last one effectively wins. Even if the prior records had a different payload.

In this way, when assembling an archive from relative paths, if the archive has multiple entries for the same path, then all payloads read in from a relative path would be identical.


Have a look-aside directory or storage. This way when a clobbering record is encountered from the tar stream, then the payload of the prior/existing file is stored to the CAS. This way the clobbering record's file payload can be extracted, but we'll have preserved the payload needed to reassemble a precise tar archive.



We could just not support tar streams that have clobbering file paths. Appending records to the archive is not incredibly common, and doesn't happen by default for most implementations. Not supporting them wouldn't be a security concern either, as if it did occur, we would reassemble an archive that doesn't validate signature/checksum, so it shouldn't be trusted anyway.

Otherwise, this will allow us to defer support for appended files as a FUTURE FEATURE.



Package asm provides the API for streaming assembly and disassembly of tar archives.

Using the `` for Packing/Unpacking the metadata for a stream, as well as an implementation of Getting/Putting the file entries' payload.



This section is empty.


This section is empty.


func NewInputTarStream

func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io.Reader, error)

NewInputTarStream wraps the Reader stream of a tar archive and provides a Reader stream of the same.

In the middle it will pack the segments and file metadata to storage.Packer `p`.

The the storage.FilePutter is where payload of files in the stream are stashed. If this stashing is not needed, you can provide a nil storage.FilePutter. Since the checksumming is still needed, then a default of NewDiscardFilePutter will be used internally

func NewOutputTarStream

func NewOutputTarStream(fg storage.FileGetter, up storage.Unpacker) io.ReadCloser

NewOutputTarStream returns an io.ReadCloser that is an assembled tar archive stream.

It takes a storage.FileGetter, for mapping the file payloads that are to be read in, and a storage.Unpacker, which has access to the rawbytes and file order metadata. With the combination of these two items, a precise assembled Tar archive is possible.

func WriteOutputTarStream

func WriteOutputTarStream(fg storage.FileGetter, up storage.Unpacker, w io.Writer) error

WriteOutputTarStream writes assembled tar archive to a writer.


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL