go.bigb.es/cacher/internal/archive

go.bigb.es/cacher @ v0.2.1 — 46be89f3 11 days ago

import "go.bigb.es/cacher/internal/archive"

Overview

Package archive streams a directory through tar+zstd (and back).

Compression level is fixed at zstd level 3 — same as the existing shell (`zstd -T0 -3`). The encoder is wrapped around an io.Writer (typically an S3 multipart Uploader's PipeWriter), so the whole pipeline stays streaming end-to-end with no on-disk tempfile.

Functions

f func DecodeDir

src
func DecodeDir(r io.Reader, dest string) error

DecodeDir extracts a tar.zst stream from r into dest. dest must exist. Any entry whose normalized path escapes dest is rejected.

f func EncodeDir

src
func EncodeDir(w io.Writer, root string) error

EncodeDir walks root in sorted relative-path order and writes a tar.zst stream into w. Symlinks are preserved (stored as tar typelink), devices/sockets/fifos are skipped.

Source files