From 6cfa0d502d477b09676329c38a060418e7bf19b7 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 10 Apr 2016 16:51:46 +0200 Subject: [PATCH] Add LoadAllSnapshots() --- src/restic/snapshot.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/restic/snapshot.go b/src/restic/snapshot.go index 6b4e87298..3cf8daedd 100644 --- a/src/restic/snapshot.go +++ b/src/restic/snapshot.go @@ -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("", sn.Paths, sn.Time) }