1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-26 12:32:31 +08:00

iterator technique for unixfs dir listing

License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
This commit is contained in:
Jeromy
2016-11-15 16:17:22 -08:00
committed by Jeromy
parent 06fb495df1
commit c8af993a8c
3 changed files with 54 additions and 51 deletions

View File

@ -102,6 +102,19 @@ func (d *Directory) switchToSharding(ctx context.Context) error {
return nil
}
func (d *Directory) ForEachLink(f func(*node.Link) error) error {
if d.shard == nil {
for _, l := range d.dirnode.Links() {
if err := f(l); err != nil {
return err
}
}
return nil
}
return d.shard.ForEachLink(f)
}
func (d *Directory) Links() ([]*node.Link, error) {
if d.shard == nil {
return d.dirnode.Links(), nil