pack

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package pack provides functions for combining and parsing pack files.

Index

Constants

View Source
const (

	// MaxHeaderSize is the max size of header including header-length field
	MaxHeaderSize = 16*1024*1024 + headerLengthSize
)

Variables

This section is empty.

Functions

func CalculateEntrySize added in v0.14.0

func CalculateEntrySize(blob restic.Blob) int

func CalculateHeaderSize added in v0.14.0

func CalculateHeaderSize(blobs []restic.Blob) int

func List

func List(k *crypto.Key, rd io.ReaderAt, size int64) (entries []restic.Blob, hdrSize uint32, err error)

List returns the list of entries found in a pack file and the length of the header (including header size and crypto overhead)

func Size added in v0.14.0

func Size(ctx context.Context, mi restic.MasterIndex, onlyHdr bool) map[restic.ID]int64

Size returns the size of all packs computed by index information. If onlyHdr is set to true, only the size of the header is returned Note that this function only gives correct sizes, if there are no duplicates in the index.

Types

type InvalidFileError

type InvalidFileError struct {
	Message string
}

InvalidFileError is return when a file is found that is not a pack file.

func (InvalidFileError) Error

func (e InvalidFileError) Error() string

type Packer

type Packer struct {
	// contains filtered or unexported fields
}

Packer is used to create a new Pack.

func NewPacker

func NewPacker(k *crypto.Key, wr io.Writer) *Packer

NewPacker returns a new Packer that can be used to pack blobs together.

func (*Packer) Add

func (p *Packer) Add(t restic.BlobType, id restic.ID, data []byte, uncompressedLength int) (int, error)

Add saves the data read from rd as a new blob to the packer. Returned is the number of bytes written to the pack plus the pack header entry size.

func (*Packer) Blobs

func (p *Packer) Blobs() []restic.Blob

Blobs returns the slice of blobs that have been written.

func (*Packer) Count

func (p *Packer) Count() int

Count returns the number of blobs in this packer.

func (*Packer) Finalize

func (p *Packer) Finalize() error

Finalize writes the header for all added blobs and finalizes the pack.

func (*Packer) HeaderFull added in v0.14.0

func (p *Packer) HeaderFull() bool

HeaderFull returns true if the pack header is full.

func (*Packer) HeaderOverhead added in v0.14.0

func (p *Packer) HeaderOverhead() int

HeaderOverhead returns an estimate of the number of bytes written by a call to Finalize.

func (*Packer) Size

func (p *Packer) Size() uint

Size returns the number of bytes written so far.

func (*Packer) String

func (p *Packer) String() string

Jump to

Keyboard shortcuts

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