Updated
On this page
API reference for the archive package — file and directory archival with atomic renames, cross-device copy-and-verify, and tar+zstd compression.
#internal/archive
#internal/archive
Package archive handles file and directory archival to the saferm archive. It supports atomic same-filesystem renames, cross-device copy-and-verify, and tar+zstd compression for directories.
#ErrFileNotFound
go
var ErrFileNotFound = errors.New("file not found")Sentinel errors.
#ErrRecursiveRequired
go
var ErrRecursiveRequired = errors.New("target is a directory; recursive flag required")#ErrConflict
go
var ErrConflict = errors.New("destination already exists")#ErrHashMismatch
go
var ErrHashMismatch = errors.New("hash mismatch after copy")#ArchiveResult
go
type ArchiveResult structArchiveResult holds the outcome of archiving a file or directory.
#Archive
go
func Archive(path string, archiveDir string, isRecursive bool) (*ArchiveResult, error)Archive moves a file or directory into archiveDir, returning the result. For files: moved directly (or copied cross-device) with SHA-256 hash. For directories: compressed into a .tar.zst archive.
#Restore
go
func Restore(uuid string, archiveDir string, destPath string, isDirectory bool, force bool) errorRestore extracts an archived file or directory to destPath.