Implement RetryBackend.List()
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
This commit is contained in:
parent
c40002246d
commit
aa333f4d49
4 changed files with 55 additions and 0 deletions
|
@ -128,3 +128,17 @@ func (be *RetryBackend) Test(ctx context.Context, h restic.Handle) (exists bool,
|
|||
})
|
||||
return exists, err
|
||||
}
|
||||
|
||||
// List runs fn for each file in the backend which has the type t.
|
||||
func (be *RetryBackend) List(ctx context.Context, t restic.FileType, fn func(restic.FileInfo) error) error {
|
||||
listed := make(map[string]struct{})
|
||||
return be.retry(ctx, fmt.Sprintf("List(%v)", t), func() error {
|
||||
return be.Backend.List(ctx, t, func(fi restic.FileInfo) error {
|
||||
if _, ok := listed[fi.Name]; ok {
|
||||
return nil
|
||||
}
|
||||
listed[fi.Name] = struct{}{}
|
||||
return fn(fi)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue