1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 10:33:34 +00:00

Add more tests for List() and fix resulting problems

This commit is contained in:
Nick Craig-Wood
2016-05-07 14:50:35 +01:00
parent 68ec6a9f5b
commit c2d0e86431
19 changed files with 369 additions and 137 deletions

View File

@@ -457,6 +457,23 @@ func (o *Lister) Get() (Object, *Dir, error) {
}
}
// Get all the objects and dirs from the listing.
func (o *Lister) GetAll() (objs []Object, dirs []*Dir, err error) {
for {
obj, dir, err := o.Get()
switch {
case err != nil:
return nil, nil, err
case obj != nil:
objs = append(objs, obj)
case dir != nil:
dirs = append(dirs, dir)
default:
return objs, dirs, nil
}
}
}
// GetObject will return an object from the listing.
// It will skip over any directories.
// Will return (nil, nil) when all objects have been returned.