mirror of
https://github.com/restic/restic.git
synced 2026-08-29 00:37:31 +00:00
repository: extract LoadTree/SaveTree
The repository has no real idea what a Tree is. So these methods never belonged there.
This commit is contained in:
@@ -67,13 +67,22 @@ func buildTreeMap(tree TestTree, m TreeMap) restic.ID {
|
||||
// TreeMap returns the trees from the map on LoadTree.
|
||||
type TreeMap map[restic.ID]*restic.Tree
|
||||
|
||||
func (t TreeMap) LoadTree(ctx context.Context, id restic.ID) (*restic.Tree, error) {
|
||||
func (t TreeMap) LoadBlob(ctx context.Context, tpe restic.BlobType, id restic.ID, buf []byte) ([]byte, error) {
|
||||
if tpe != restic.TreeBlob {
|
||||
return nil, errors.New("can only load trees")
|
||||
}
|
||||
tree, ok := t[id]
|
||||
if !ok {
|
||||
return nil, errors.New("tree not found")
|
||||
}
|
||||
|
||||
return tree, nil
|
||||
tbuf, err := json.Marshal(tree)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tbuf = append(tbuf, '\n')
|
||||
|
||||
return tbuf, nil
|
||||
}
|
||||
|
||||
func (t TreeMap) Connections() uint {
|
||||
|
||||
Reference in New Issue
Block a user