Add LoadAllSnapshots()

This commit is contained in:
Alexander Neumann 2016-04-10 16:51:46 +02:00
parent a996dbb9d6
commit 6cfa0d502d

View file

@ -60,6 +60,22 @@ func LoadSnapshot(repo *repository.Repository, id backend.ID) (*Snapshot, error)
return sn, nil 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 { func (sn Snapshot) String() string {
return fmt.Sprintf("<Snapshot of %v at %s>", sn.Paths, sn.Time) return fmt.Sprintf("<Snapshot of %v at %s>", sn.Paths, sn.Time)
} }