go.bigb.es/cacher @ v0.2.2 — 333189a2 11 days ago
import "go.bigb.es/cacher/internal/archive"
DecodeDir extracts a tar.zst stream from r into dest. dest must exist. Any entry whose normalized path escapes dest is rejected.
Read-only entries are the normal case, not an exotic one: the Go module cache is 0555 directories and 0444 files throughout. So directories are created writable and their recorded mode is applied at the very end, and files are written writable and chmod'ed after the copy. Restoring the archived mode as we go would lock the extraction out of the tree it is still filling in.
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.