From 34495cf820f4d7c93e5ebba751b71d1fa3d6c1be Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Wed, 16 Oct 2024 05:03:38 -1000 Subject: [PATCH] Add LsIter to iterate items from UnixfsAPI interfaces --- core/coreiface/unixfs.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/coreiface/unixfs.go b/core/coreiface/unixfs.go index 32bedd93ea2..6bdcdfa5045 100644 --- a/core/coreiface/unixfs.go +++ b/core/coreiface/unixfs.go @@ -2,6 +2,7 @@ package iface import ( "context" + "iter" "os" "time" @@ -97,7 +98,6 @@ type UnixfsAPI interface { Ls(context.Context, path.Path, ...options.UnixfsLsOption) (<-chan DirEntry, <-chan error) } -/* TODO: Uncomment after go1.23 required. // LsIter returns a go iterator that allows ranging over DirEntry results. // Iteration stops if the context is canceled or if the iterator yields an // error. @@ -120,9 +120,8 @@ func LsIter(ctx context.Context, api UnixfsAPI, p path.Path, opts ...options.Uni return } } - if err != <-asyncErr; err != nil { - yield(nil, err) + if err := <-asyncErr; err != nil { + yield(DirEntry{}, err) } } } -*/