Add LoadAllSnapshots()
This commit is contained in:
parent
a996dbb9d6
commit
6cfa0d502d
1 changed files with 16 additions and 0 deletions
|
@ -60,6 +60,22 @@ func LoadSnapshot(repo *repository.Repository, id backend.ID) (*Snapshot, error)
|
|||
return sn, nil
|
||||
}
|
||||
|
||||
func LoadAllSnapshots(repo *repository.Repository) (snapshots []*Snapshot, err error) {
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
|
||||
for id := range repo.List(backend.Snapshot, done) {
|
||||
sn, err := LoadSnapshot(repo, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snapshots = append(snapshots, sn)
|
||||
}
|
||||
|
||||
return snapshots, nil
|
||||
}
|
||||
|
||||
func (sn Snapshot) String() string {
|
||||
return fmt.Sprintf("<Snapshot of %v at %s>", sn.Paths, sn.Time)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue