snapshot

package
v0.0.0-...-e308f56 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package snapshot provides streaming directory archival and restoration using tar and zstd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, remote cache.Cache, key cache.Key, directory string, ttl time.Duration, excludePatterns []string, threads int, extraHeaders ...http.Header) error

Create archives a directory using tar with zstd compression, then uploads to the cache.

The archive preserves all file permissions, ownership, and symlinks. The operation is fully streaming - no temporary files are created. Exclude patterns use tar's --exclude syntax. threads controls zstd parallelism; 0 uses all available CPU cores. Any extra headers are merged into the cache metadata alongside the default Content-Type and Content-Disposition headers.

func CreatePaths

func CreatePaths(ctx context.Context, remote cache.Cache, key cache.Key, baseDir, archiveName string, includePaths []string, ttl time.Duration, excludePatterns []string, threads int, extraHeaders ...http.Header) error

CreatePaths archives named paths within baseDir using tar with zstd compression, then uploads the resulting archive to the cache.

The archive preserves all file permissions, ownership, and symlinks. Each entry in includePaths is archived relative to baseDir and must exist. This allows callers to archive either an entire directory with "." or a specific subtree such as "lfs" while preserving that relative path prefix. Exclude patterns use tar's --exclude syntax. threads controls zstd parallelism; 0 uses all available CPU cores.

func Extract

func Extract(ctx context.Context, r io.Reader, directory string, threads int) error

Extract decompresses a zstd+tar stream into directory, preserving all file permissions, ownership, and symlinks. threads controls zstd parallelism; 0 uses all available CPU cores.

func Restore

func Restore(ctx context.Context, remote cache.Cache, key cache.Key, directory string, threads int) error

Restore downloads an archive from the cache and extracts it to a directory.

The archive is decompressed with zstd and extracted with tar, preserving all file permissions, ownership, and symlinks. The operation is fully streaming - no temporary files are created. threads controls zstd parallelism; 0 uses all available CPU cores.

func StreamTo

func StreamTo(ctx context.Context, w io.Writer, directory string, excludePatterns []string, threads int) error

StreamTo archives a directory using tar with zstd compression and streams the output directly to w. Unlike Create, it does not upload to any cache backend. This is used on cache miss to serve the client immediately while a background job populates the cache.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL