1
0
mirror of https://github.com/restic/restic.git synced 2024-06-28 08:00:52 +02:00
restic/internal/restic/repository.go

68 lines
1.9 KiB
Go
Raw Normal View History

package restic
2017-06-03 17:39:57 +02:00
import (
"context"
2017-07-23 14:21:03 +02:00
"github.com/restic/restic/internal/crypto"
2017-06-03 17:39:57 +02:00
)
2016-08-31 23:07:50 +02:00
// Repository stores data in a backend. It provides high-level functions and
// transparently encrypts/decrypts data.
type Repository interface {
// Backend returns the backend used by the repository
Backend() Backend
2016-08-31 23:07:50 +02:00
Key() *crypto.Key
2016-08-31 22:39:36 +02:00
SetIndex(Index)
2016-08-31 20:29:54 +02:00
Index() Index
2017-06-04 11:16:55 +02:00
SaveFullIndex(context.Context) error
SaveIndex(context.Context) error
LoadIndex(context.Context) error
2016-08-31 20:29:54 +02:00
Config() Config
LookupBlobSize(ID, BlobType) (uint, error)
2018-01-23 21:21:54 +01:00
// List calls the function fn for each file of type t in the repository.
// When an error is returned by fn, processing stops and List() returns the
// error.
//
// The function fn is called in the same Goroutine List() was called from.
List(ctx context.Context, t FileType, fn func(ID, int64) error) error
2017-06-04 11:16:55 +02:00
ListPack(context.Context, ID) ([]Blob, int64, error)
Flush(context.Context) error
2017-06-04 11:16:55 +02:00
SaveUnpacked(context.Context, FileType, []byte) (ID, error)
SaveJSONUnpacked(context.Context, FileType, interface{}) (ID, error)
2016-08-31 20:29:54 +02:00
2017-06-04 11:16:55 +02:00
LoadJSONUnpacked(context.Context, FileType, ID, interface{}) error
LoadAndDecrypt(context.Context, FileType, ID) ([]byte, error)
2017-06-04 11:16:55 +02:00
LoadBlob(context.Context, BlobType, ID, []byte) (int, error)
SaveBlob(context.Context, BlobType, []byte, ID) (ID, error)
2016-09-03 20:55:22 +02:00
2017-06-04 11:16:55 +02:00
LoadTree(context.Context, ID) (*Tree, error)
SaveTree(context.Context, *Tree) (ID, error)
2016-08-31 20:29:54 +02:00
}
2016-08-31 22:39:36 +02:00
// Lister allows listing files in a backend.
type Lister interface {
List(context.Context, FileType, func(FileInfo) error) error
2016-08-31 22:39:36 +02:00
}
2016-08-31 20:58:57 +02:00
// Index keeps track of the blobs are stored within files.
2016-08-31 20:29:54 +02:00
type Index interface {
2016-08-31 20:58:57 +02:00
Has(ID, BlobType) bool
Lookup(ID, BlobType) ([]PackedBlob, error)
2016-08-31 23:07:50 +02:00
Count(BlobType) uint
2017-06-18 14:45:02 +02:00
// Each returns a channel that yields all blobs known to the index. When
// the context is cancelled, the background goroutine terminates. This
// blocks any modification of the index.
Each(ctx context.Context) <-chan PackedBlob
2016-08-31 20:29:54 +02:00
}