serve restic: use walk.ListR for listing

This is effectively what the old code did anyway so this should not
make any functional changes.
This commit is contained in:
Nick Craig-Wood 2019-01-21 16:58:27 +00:00
parent d5f2df2f3d
commit e5f4210b09

View file

@ -330,25 +330,12 @@ func (s *server) listObjects(w http.ResponseWriter, r *http.Request, remote stri
ls := listItems{}
// if remote supports ListR use that directly, otherwise use recursive Walk
var err error
if ListR := s.f.Features().ListR; ListR != nil {
err = ListR(remote, func(entries fs.DirEntries) error {
for _, entry := range entries {
ls.add(entry)
}
return nil
})
} else {
err = walk.Walk(s.f, remote, true, -1, func(path string, entries fs.DirEntries, err error) error {
if err == nil {
for _, entry := range entries {
ls.add(entry)
}
}
return err
})
}
err := walk.ListR(s.f, remote, true, -1, walk.ListObjects, func(entries fs.DirEntries) error {
for _, entry := range entries {
ls.add(entry)
}
return nil
})
if err != nil {
_, err = fserrors.Cause(err)
if err != fs.ErrorDirNotFound {