mirror of
https://github.com/restic/restic.git
synced 2026-11-14 06:44:03 +00:00
Move restore functionality into khepri package
This commit is contained in:
1 parent
2428843faa
commit
d66996e648
3 files changed
+162
-144
No files matched your search
+18
@@ -18,6 +18,7 @@ type Snapshot struct {
|
||||
UID string `json:"uid,omitempty"`
|
||||
GID string `json:"gid,omitempty"`
|
||||
id ID `json:omit`
|
||||
repo *Repository
|
||||
}
|
||||
|
||||
func NewSnapshot(dir string) *Snapshot {
|
||||
@@ -84,10 +85,27 @@ func LoadSnapshot(repo *Repository, id ID) (*Snapshot, error) {
|
||||
}
|
||||
|
||||
sn.id = id
|
||||
sn.repo = repo
|
||||
|
||||
return sn, nil
|
||||
}
|
||||
|
||||
func (sn *Snapshot) RestoreAt(path string) error {
|
||||
err := os.MkdirAll(path, 0700)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if sn.Tree == nil {
|
||||
sn.Tree, err = NewTreeFromRepo(sn.repo, sn.Content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return sn.Tree.CreateAt(path)
|
||||
}
|
||||
|
||||
func (sn *Snapshot) ID() ID {
|
||||
return sn.id
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user