Helper function to load snapshot root directories (#1796)
## Description Add a helper function that allows loading the root directory of a snapshot given the snapshot manifest. This will allow future code for merging directory hierarchies to be tested without having to involve an actual instance of kopia with some previously created snapshots. ## Type of change - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) * #1740 ## Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
01b8111404
commit
c1a0b74d22
@ -6,6 +6,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/kopia/kopia/fs"
|
||||
"github.com/kopia/kopia/repo"
|
||||
"github.com/kopia/kopia/repo/blob"
|
||||
"github.com/kopia/kopia/repo/compression"
|
||||
@ -13,6 +14,7 @@ import (
|
||||
"github.com/kopia/kopia/repo/manifest"
|
||||
"github.com/kopia/kopia/snapshot"
|
||||
"github.com/kopia/kopia/snapshot/policy"
|
||||
"github.com/kopia/kopia/snapshot/snapshotfs"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common"
|
||||
@ -47,6 +49,10 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
type snapshotLoader interface {
|
||||
SnapshotRoot(man *snapshot.Manifest) (fs.Entry, error)
|
||||
}
|
||||
|
||||
type ErrorRepoAlreadyExists struct {
|
||||
common.Err
|
||||
}
|
||||
@ -60,7 +66,10 @@ func IsRepoAlreadyExistsError(e error) bool {
|
||||
return errors.As(e, &erae)
|
||||
}
|
||||
|
||||
var _ snapshotManager = &conn{}
|
||||
var (
|
||||
_ snapshotManager = &conn{}
|
||||
_ snapshotLoader = &conn{}
|
||||
)
|
||||
|
||||
type conn struct {
|
||||
storage storage.Storage
|
||||
@ -389,3 +398,7 @@ func (w *conn) LoadSnapshots(
|
||||
) ([]*snapshot.Manifest, error) {
|
||||
return snapshot.LoadSnapshots(ctx, w.Repository, ids)
|
||||
}
|
||||
|
||||
func (w *conn) SnapshotRoot(man *snapshot.Manifest) (fs.Entry, error) {
|
||||
return snapshotfs.SnapshotRoot(w.Repository, man)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user