index

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package index contains various data structures for indexing content in a repository or backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	Packs    map[restic.ID]Pack
	IndexIDs restic.IDSet
}

Index contains information about blobs and packs stored in a repo.

func Load

func Load(ctx context.Context, repo ListLoader, p *restic.Progress) (*Index, error)

Load creates an index by loading all index files from the repo.

func New

func New(ctx context.Context, repo Lister, ignorePacks restic.IDSet, p *restic.Progress) (idx *Index, invalidFiles restic.IDs, err error)

New creates a new index for repo from scratch. InvalidFiles contains all IDs of files that cannot be listed successfully.

func (*Index) AddPack

func (idx *Index) AddPack(id restic.ID, size int64, entries []restic.Blob) error

AddPack adds a pack to the index. If this pack is already in the index, an error is returned.

func (*Index) DuplicateBlobs

func (idx *Index) DuplicateBlobs() (dups restic.BlobSet)

DuplicateBlobs returns a list of blobs that are stored more than once in the repo.

func (*Index) PacksForBlobs

func (idx *Index) PacksForBlobs(blobs restic.BlobSet) (packs restic.IDSet)

PacksForBlobs returns the set of packs in which the blobs are contained.

func (*Index) RemovePack

func (idx *Index) RemovePack(id restic.ID) error

RemovePack deletes a pack from the index.

func (*Index) Save

func (idx *Index) Save(ctx context.Context, repo Saver, supersedes restic.IDs) (restic.IDs, error)

Save writes the complete index to the repo.

type ListLoader added in v0.9.7

type ListLoader interface {
	Lister
	LoadJSONUnpacked(context.Context, restic.FileType, restic.ID, interface{}) error
}

ListLoader allows listing files and their content, in addition to loading and unmarshaling JSON files.

type Lister added in v0.9.7

type Lister interface {
	// List runs fn for all files of type t in the repo.
	List(ctx context.Context, t restic.FileType, fn func(restic.ID, int64) error) error

	// ListPack returns the list of blobs saved in the pack id and the length
	// of the file as stored in the backend.
	ListPack(ctx context.Context, id restic.ID, size int64) ([]restic.Blob, int64, error)
}

Lister lists files and their contents

type Pack

type Pack struct {
	ID      restic.ID
	Size    int64
	Entries []restic.Blob
}

Pack contains information about the contents of a pack.

type Saver added in v0.9.7

type Saver interface {
	SaveJSONUnpacked(ctx context.Context, t restic.FileType, item interface{}) (restic.ID, error)
}

Saver saves structures as JSON.

Jump to

Keyboard shortcuts

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