Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

serve restic: use ListR (--fast-list) if available

Nick Craig-Wood1313b529ff83
diff --git a/cmd/serve/restic/restic.go b/cmd/serve/restic/restic.go
index 2bbd9acc1..044cc4178 100644
--- a/cmd/serve/restic/restic.go
+++ b/cmd/serve/restic/restic.go
@@ -405,14 +405,25 @@ func (s *server) listObjects(w http.ResponseWriter, r *http.Request, remote stri
// make sure an empty list is returned, and not a 'nil' value
ls := listItems{}
- err := walk.Walk(s.f, remote, true, -1, func(path string, entries fs.DirEntries, err error) error {
- if err == nil {
+ // 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 err
- })
+ 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
+ })
+ }
if err != nil {
_, err = fserrors.Cause(err)