mirror of
https://github.com/restic/restic.git
synced 2025-10-19 15:43:21 +00:00
restic: move interfaces between files to prepare refactor
This commit is contained in:
parent
13e476e1eb
commit
c85b157e0e
3 changed files with 21 additions and 20 deletions
|
@ -8,18 +8,6 @@ import (
|
|||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// Loader loads a blob from a repository.
|
||||
type Loader interface {
|
||||
LoadBlob(context.Context, BlobType, ID, []byte) ([]byte, error)
|
||||
LookupBlobSize(tpe BlobType, id ID) (uint, bool)
|
||||
Connections() uint
|
||||
}
|
||||
|
||||
type FindBlobSet interface {
|
||||
Has(bh BlobHandle) bool
|
||||
Insert(bh BlobHandle)
|
||||
}
|
||||
|
||||
// FindUsedBlobs traverses the tree ID and adds all seen blobs (trees and data
|
||||
// blobs) to the set blobs. Already seen tree blobs will not be visited again.
|
||||
func FindUsedBlobs(ctx context.Context, repo Loader, treeIDs IDs, blobs FindBlobSet, p *progress.Counter) error {
|
||||
|
|
|
@ -168,9 +168,30 @@ type ListBlobser interface {
|
|||
ListBlobs(ctx context.Context, fn func(PackedBlob)) error
|
||||
}
|
||||
|
||||
type BlobLoader interface {
|
||||
LoadBlob(context.Context, BlobType, ID, []byte) ([]byte, error)
|
||||
}
|
||||
|
||||
type BlobSaver interface {
|
||||
SaveBlob(context.Context, BlobType, []byte, ID, bool) (ID, bool, int, error)
|
||||
}
|
||||
|
||||
// Loader loads a blob from a repository.
|
||||
type Loader interface {
|
||||
LoadBlob(context.Context, BlobType, ID, []byte) ([]byte, error)
|
||||
LookupBlobSize(tpe BlobType, id ID) (uint, bool)
|
||||
Connections() uint
|
||||
}
|
||||
|
||||
type WarmupJob interface {
|
||||
// HandleCount returns the number of handles that are currently warming up.
|
||||
HandleCount() int
|
||||
// Wait waits for all handles to be warm.
|
||||
Wait(ctx context.Context) error
|
||||
}
|
||||
|
||||
// FindBlobSet is a set of blob handles used by prune.
|
||||
type FindBlobSet interface {
|
||||
Has(bh BlobHandle) bool
|
||||
Insert(bh BlobHandle)
|
||||
}
|
||||
|
|
|
@ -104,10 +104,6 @@ func (t *Tree) Subtrees() (trees IDs) {
|
|||
return trees
|
||||
}
|
||||
|
||||
type BlobLoader interface {
|
||||
LoadBlob(context.Context, BlobType, ID, []byte) ([]byte, error)
|
||||
}
|
||||
|
||||
// LoadTree loads a tree from the repository.
|
||||
func LoadTree(ctx context.Context, r BlobLoader, id ID) (*Tree, error) {
|
||||
debug.Log("load tree %v", id)
|
||||
|
@ -126,10 +122,6 @@ func LoadTree(ctx context.Context, r BlobLoader, id ID) (*Tree, error) {
|
|||
return t, nil
|
||||
}
|
||||
|
||||
type BlobSaver interface {
|
||||
SaveBlob(context.Context, BlobType, []byte, ID, bool) (ID, bool, int, error)
|
||||
}
|
||||
|
||||
// SaveTree stores a tree into the repository and returns the ID. The ID is
|
||||
// checked against the index. The tree is only stored when the index does not
|
||||
// contain the ID.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue