mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
restic: move interfaces between files to prepare refactor
This commit is contained in:
@@ -8,18 +8,6 @@ import (
|
|||||||
"golang.org/x/sync/errgroup"
|
"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
|
// 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.
|
// 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 {
|
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
|
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 {
|
type WarmupJob interface {
|
||||||
// HandleCount returns the number of handles that are currently warming up.
|
// HandleCount returns the number of handles that are currently warming up.
|
||||||
HandleCount() int
|
HandleCount() int
|
||||||
// Wait waits for all handles to be warm.
|
// Wait waits for all handles to be warm.
|
||||||
Wait(ctx context.Context) error
|
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
|
return trees
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlobLoader interface {
|
|
||||||
LoadBlob(context.Context, BlobType, ID, []byte) ([]byte, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadTree loads a tree from the repository.
|
// LoadTree loads a tree from the repository.
|
||||||
func LoadTree(ctx context.Context, r BlobLoader, id ID) (*Tree, error) {
|
func LoadTree(ctx context.Context, r BlobLoader, id ID) (*Tree, error) {
|
||||||
debug.Log("load tree %v", id)
|
debug.Log("load tree %v", id)
|
||||||
@@ -126,10 +122,6 @@ func LoadTree(ctx context.Context, r BlobLoader, id ID) (*Tree, error) {
|
|||||||
return t, nil
|
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
|
// 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
|
// checked against the index. The tree is only stored when the index does not
|
||||||
// contain the ID.
|
// contain the ID.
|
||||||
|
|||||||
Reference in New Issue
Block a user