Documentation
¶
Index ¶
Constants ¶
View Source
const ( // ContentHashAlgorithm is the hash algorithm used for content addressing. ContentHashAlgorithm = "xxh3" // DirPerm is the default permission for directories. DirPerm = 0o755 // TempContentPattern is the pattern for temporary content files. TempContentPattern = ".content-*" // TempSnapshotPattern is the pattern for temporary snapshot files. TempSnapshotPattern = ".snapshot-*" )
Variables ¶
This section is empty.
Functions ¶
func ContentDigest ¶
ContentDigest returns the digest by adding the hash algorithm prefix.
func ParseFilenameFromDigest ¶
ParseFilenameFromDigest parses the filename from the digest.
Types ¶
type File ¶
type File struct {
// RelativePath is the relative path of the file.
RelativePath string
// ReadOnly indicates whether the file is read-only.
ReadOnly bool
}
File defines the file information for snapshotting and restoring.
type Storage ¶
type Storage interface {
// StatContent returns the content info.
StatContent(ctx context.Context, baseDir string, file File) (os.FileInfo, error)
// WriteContent writes the content to the storage.
WriteContent(ctx context.Context, baseDir string, file File) (os.FileInfo, error)
// GetContentPath returns the path to the content.
GetContentPath(ctx context.Context, filename string) string
// StatSnapshot returns the snapshot info.
StatSnapshot(ctx context.Context, filename string) (os.FileInfo, error)
// HardlinkSnapshot creates a hardlink to the snapshot.
HardlinkSnapshot(ctx context.Context, baseDir string, srcfile File, destFilename string) error
// RestoreSnapshotFromContent restores the snapshot from content.
RestoreSnapshotFromContent(ctx context.Context, filename string) error
// Export outputs the content or snapshot to output directory.
// It will copy the content if the file is not read-only, otherwise it will hardlink from snapshot.
Export(ctx context.Context, outputDir string, file metadata.File, srcFilename string) error
// Prune removes unused content and snapshot files.
Prune(ctx context.Context, filename string) error
}
Storage is an interface for storage.
Click to show internal directories.
Click to hide internal directories.