package tar

import "github.com/influxdata/influxdb/pkg/tar"

Index

Functions

func Restore

func Restore(r io.Reader, dir string) error

Restore reads a tar archive from r and extracts all of its files into dir, using only the base name of each file.

func SinceFilterTarFile

func SinceFilterTarFile(since time.Time) func(f os.FileInfo, shardRelativePath, fullPath string, tw *tar.Writer) error

Generates a filtering function for Stream that checks an incoming file, and only writes the file to the stream if its mod time is later than since. Example: to tar only files newer than a certain datetime, use tar.Stream(w, dir, relativePath, SinceFilterTarFile(datetime))

func Stream

func Stream(w io.Writer, dir, relativePath string, writeFunc func(f os.FileInfo, shardRelativePath, fullPath string, tw *tar.Writer) error) error

Stream is a convenience function for creating a tar of a shard dir. It walks over the directory and subdirs, possibly writing each file to a tar writer stream. By default StreamFile is used, which will result in all files being written. A custom writeFunc can be passed so that each file may be written, modified+written, or skipped depending on the custom logic.

func StreamFile

func StreamFile(f os.FileInfo, shardRelativePath, fullPath string, tw *tar.Writer) error

stream a single file to tw, extending the header name using the shardRelativePath

func StreamRenameFile

func StreamRenameFile(f os.FileInfo, tarHeaderFileName, relativePath, fullPath string, tw *tar.Writer) error

/ Stream a single file to tw, using tarHeaderFileName instead of the actual filename e.g., when we want to write a *.tmp file using the original file's non-tmp name.

func Untar

func Untar(dir string, r io.Reader) (rErr error)

Untar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dir' along the way, and writing any files

Source Files

stream.go untar.go

Version
v1.12.0 (latest)
Published
Apr 8, 2025
Platform
linux/amd64
Imports
11 packages
Last checked
2 days ago

Tools for package owners.