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:
17
fs/fs.go
17
fs/fs.go
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user