2016-08-31 17:10:10 +00:00
|
|
|
package restic
|
|
|
|
|
2017-06-03 15:39:57 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"restic/crypto"
|
|
|
|
)
|
2016-08-31 21:07:50 +00:00
|
|
|
|
2016-08-31 17:10:10 +00: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 21:07:50 +00:00
|
|
|
Key() *crypto.Key
|
|
|
|
|
2016-08-31 20:39:36 +00:00
|
|
|
SetIndex(Index)
|
2016-08-31 18:29:54 +00:00
|
|
|
|
|
|
|
Index() Index
|
2017-06-04 09:16:55 +00:00
|
|
|
SaveFullIndex(context.Context) error
|
|
|
|
SaveIndex(context.Context) error
|
|
|
|
LoadIndex(context.Context) error
|
2016-08-31 18:29:54 +00:00
|
|
|
|
|
|
|
Config() Config
|
|
|
|
|
2016-09-01 20:42:12 +00:00
|
|
|
LookupBlobSize(ID, BlobType) (uint, error)
|
|
|
|
|
2017-06-04 09:16:55 +00:00
|
|
|
List(context.Context, FileType) <-chan ID
|
|
|
|
ListPack(context.Context, ID) ([]Blob, int64, error)
|
2016-09-01 20:42:12 +00:00
|
|
|
|
|
|
|
Flush() error
|
|
|
|
|
2017-06-04 09:16:55 +00:00
|
|
|
SaveUnpacked(context.Context, FileType, []byte) (ID, error)
|
|
|
|
SaveJSONUnpacked(context.Context, FileType, interface{}) (ID, error)
|
2016-08-31 18:29:54 +00:00
|
|
|
|
2017-06-04 09:16:55 +00:00
|
|
|
LoadJSONUnpacked(context.Context, FileType, ID, interface{}) error
|
|
|
|
LoadAndDecrypt(context.Context, FileType, ID) ([]byte, error)
|
2016-09-03 09:22:01 +00:00
|
|
|
|
2017-06-04 09:16:55 +00:00
|
|
|
LoadBlob(context.Context, BlobType, ID, []byte) (int, error)
|
|
|
|
SaveBlob(context.Context, BlobType, []byte, ID) (ID, error)
|
2016-09-03 18:55:22 +00:00
|
|
|
|
2017-06-04 09:16:55 +00:00
|
|
|
LoadTree(context.Context, ID) (*Tree, error)
|
|
|
|
SaveTree(context.Context, *Tree) (ID, error)
|
2016-08-31 18:29:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-31 20:51:35 +00:00
|
|
|
// Deleter removes all data stored in a backend/repo.
|
|
|
|
type Deleter interface {
|
2017-06-03 15:39:57 +00:00
|
|
|
Delete(context.Context) error
|
2016-08-31 20:51:35 +00:00
|
|
|
}
|
|
|
|
|
2016-08-31 20:39:36 +00:00
|
|
|
// Lister allows listing files in a backend.
|
|
|
|
type Lister interface {
|
2017-06-03 15:39:57 +00:00
|
|
|
List(context.Context, FileType) <-chan string
|
2016-08-31 20:39:36 +00:00
|
|
|
}
|
|
|
|
|
2016-08-31 18:58:57 +00:00
|
|
|
// Index keeps track of the blobs are stored within files.
|
2016-08-31 18:29:54 +00:00
|
|
|
type Index interface {
|
2016-08-31 18:58:57 +00:00
|
|
|
Has(ID, BlobType) bool
|
|
|
|
Lookup(ID, BlobType) ([]PackedBlob, error)
|
2016-08-31 21:07:50 +00:00
|
|
|
Count(BlobType) uint
|
2017-06-18 12:45:02 +00: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 18:29:54 +00:00
|
|
|
}
|