data

package
v0.0.0-...-d9d993d Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = clues.New("not found")
	ErrNoData   = clues.New("no data")
)

Functions

func NewLazyItem

func NewLazyItem(
	ctx context.Context,
	itemGetter ItemDataGetter,
	itemID string,
	modTime time.Time,
	counter *count.Bus,
	errs *fault.Bus,
) *lazyItem

func NewLazyItemWithInfo

func NewLazyItemWithInfo(
	ctx context.Context,
	itemGetter ItemDataGetter,
	itemID string,
	modTime time.Time,
	counter *count.Bus,
	errs *fault.Bus,
) *lazyItemWithInfo

func NewPrefetchedItem

func NewPrefetchedItem(
	reader io.ReadCloser,
	itemID string,
	modTime time.Time,
) (*prefetchedItem, error)

func NewPrefetchedItemWithInfo

func NewPrefetchedItemWithInfo(
	reader io.ReadCloser,
	itemID string,
	info details.ItemInfo,
) (*prefetchedItemWithInfo, error)

func NewTombstoneCollection

func NewTombstoneCollection(
	prev path.Path,
	opts control.Options,
	counter *count.Bus,
) *tombstoneCollection

func SortRestoreCollections

func SortRestoreCollections(rcs []RestoreCollection)

SortRestoreCollections performs an in-place sort on the provided collection.

Types

type BackupCollection

type BackupCollection interface {
	Collection
	// PreviousPath returns the path.Path this collection used to reside at
	// (according to the M365 ID for the container) if the collection was moved or
	// renamed. Returns nil if the collection is new.
	PreviousPath() path.Path
	// State represents changes to the Collection compared to the last backup
	// involving the Collection. State changes are based on the M365 ID of the
	// Collection, not just the path the collection resides at. Collections that
	// are in the same location as they were in the previous backup should be
	// marked as NotMovedState. Renaming or reparenting the Collection counts as
	// Moved. Collections marked as Deleted will be removed from the current
	// backup along with all items and Collections below them in the hierarchy
	// unless said items/Collections were moved.
	State() CollectionState
	// DoNotMergeItems informs kopia that the collection is rebuilding its contents
	// from scratch, and that any items currently stored at the previousPath should
	// be skipped during the process of merging historical data into the new backup.
	// This flag is normally expected to be false.  It should only be flagged under
	// specific circumstances.  Example: if the link token used for incremental queries
	// expires or otherwise becomes unusable, thus requiring the backup producer to
	// re-discover all data in the container.  This flag only affects the path of the
	// collection, and does not cascade to subfolders.
	DoNotMergeItems() bool
}

BackupCollection is an extension of Collection that is used during backups.

type BaseCollection

type BaseCollection struct {
	Counter *count.Bus
	// contains filtered or unexported fields
}

BaseCollection contains basic functionality like returning path, location, and state information. It can be embedded in other implementations to provide this functionality.

Functionality like how items are fetched is left to the embedding struct.

func NewBaseCollection

func NewBaseCollection(
	curr, prev path.Path,
	location *path.Builder,
	ctrlOpts control.Options,
	doNotMergeItems bool,
	counter *count.Bus,
) BaseCollection

func (BaseCollection) Category

func (col BaseCollection) Category() path.CategoryType

func (BaseCollection) DoNotMergeItems

func (col BaseCollection) DoNotMergeItems() bool

func (*BaseCollection) FullPath

func (col *BaseCollection) FullPath() path.Path

FullPath returns the BaseCollection's fullPath []string

func (*BaseCollection) LocationPath

func (col *BaseCollection) LocationPath() *path.Builder

LocationPath produces the BaseCollection's full path, but with display names instead of IDs in the folders. Only populated for Calendars.

func (BaseCollection) Opts

func (col BaseCollection) Opts() control.Options

func (BaseCollection) PreviousPath

func (col BaseCollection) PreviousPath() path.Path

func (BaseCollection) State

func (col BaseCollection) State() CollectionState

type Collection

type Collection interface {
	// Items returns a channel from which items in the collection can be read.
	// Each returned struct contains the next item in the collection
	// The channel is closed when there are no more items in the collection or if
	// an unrecoverable error caused an early termination in the sender.
	Items(ctx context.Context, errs *fault.Bus) <-chan Item
	// FullPath returns a path struct that acts as a metadata tag for this
	// Collection.
	FullPath() path.Path
}

A Collection represents the set of data within a single logical location denoted by FullPath.

type CollectionState

type CollectionState int
const (
	NewState      CollectionState = 0
	NotMovedState CollectionState = 1
	MovedState    CollectionState = 2
	DeletedState  CollectionState = 3
)

func StateOf

func StateOf(
	prev, curr path.Path,
	counter *count.Bus,
) CollectionState

StateOf lets us figure out the state of the collection from the previous and current path

func (CollectionState) String

func (cs CollectionState) String() string

type CollectionStats

type CollectionStats struct {
	Folders,
	Objects,
	Successes int
	Bytes   int64
	Details string
}

func (CollectionStats) IsZero

func (cs CollectionStats) IsZero() bool

func (CollectionStats) String

func (cs CollectionStats) String() string

type FetchItemByNamer

type FetchItemByNamer interface {
	// Fetch retrieves an item with the given name from the Collection if it
	// exists. Items retrieved with Fetch may still appear in the channel returned
	// by Items().
	FetchItemByName(ctx context.Context, name string) (Item, error)
}

type FetchRestoreCollection

type FetchRestoreCollection struct {
	Collection
	FetchItemByNamer
}

type Item

type Item interface {
	// ToReader returns an io.Reader with the item's data
	ToReader() io.ReadCloser
	// ID provides a unique identifier for this item
	ID() string
	// Deleted returns true if the item represented by this Stream has been
	// deleted and should be removed from the current in-progress backup.
	Deleted() bool
}

Item represents a single item within a Collection

func NewDeletedItem

func NewDeletedItem(itemID string) Item

type ItemDataGetter

type ItemDataGetter interface {
	GetData(
		context.Context,
		*fault.Bus,
	) (io.ReadCloser, *details.ItemInfo, bool, error)
}

type ItemInfo

type ItemInfo interface {
	Info() (details.ItemInfo, error)
}

ItemInfo returns the details.ItemInfo for the item.

type ItemModTime

type ItemModTime interface {
	ModTime() time.Time
}

ItemModTime provides the last modified time of the item.

If an item implements ItemModTime and ItemInfo it should return the same value here as in item.Info().Modified().

type ItemSize

type ItemSize interface {
	Size() int64
}

ItemSize returns the size of the item in bytes.

type LocationPather

type LocationPather interface {
	LocationPath() *path.Builder
}

LocationPather provides a LocationPath describing the path with Display Names instead of canonical IDs

type NoFetchRestoreCollection

type NoFetchRestoreCollection struct {
	Collection
}

NoFetchRestoreCollection is a wrapper for a Collection that returns ErrNotFound for all Fetch calls.

func (NoFetchRestoreCollection) FetchItemByName

func (c NoFetchRestoreCollection) FetchItemByName(context.Context, string) (Item, error)

type PreviousLocationPather

type PreviousLocationPather interface {
	LocationPather
	PreviousLocationPath() details.LocationIDer
}

PreviousLocationPather provides both the current location of the collection as well as the location of the item in the previous backup.

TODO(ashmrtn): If we guarantee that we persist the location of collections in addition to the path of the item then we could just have a single *LocationPather interface with current and previous location functions.

type RestoreCollection

type RestoreCollection interface {
	Collection
	FetchItemByNamer
}

RestoreCollection is an extension of Collection that is used during restores.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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