@cryptotaxi247 / kubo / commits / 9f41461f5

coreapi: stream only ls, handle storting in command

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@a62acc82d4b5f8135f1d1249a22e91572a9a03c0 This commit was moved from ipfs/boxo@328e6f8ac9b4229e990201a93954213be992c45d

Łukasz Magiera committed Feb 2, 2019 at 03:42 UTC 9f41461f572ba3ed3e2a9c247521690595705d3d
3 files changed +3 -35
core/coreiface/options/unixfs.go
-14
@@ -43,8 +43,6 @@ type UnixfsAddSettings struct {
43 }
44
45 type UnixfsLsSettings struct {
46 - Async bool
47 -
46 ResolveType bool
47 ResolveSize bool
48 }
@@ -132,8 +130,6 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix,
130
131 func UnixfsLsOptions(opts ...UnixfsLsOption) (*UnixfsLsSettings, error) {
132 options := &UnixfsLsSettings{
135 - Async: true,
136 -
133 ResolveSize: true,
134 ResolveType: true,
135 }
@@ -317,16 +313,6 @@ func (unixfsOpts) Nocopy(enable bool) UnixfsAddOption {
313 }
314 }
315
320 -// Async tells ls to return results as soon as they are available, which can be
321 -// useful for listing HAMT directories. When this option is set to true returned
322 -// results won't be returned in order
323 -func (unixfsOpts) Async(async bool) UnixfsLsOption {
324 - return func(settings *UnixfsLsSettings) error {
325 - settings.Async = async
326 - return nil
327 - }
328 -}
329 -
316 func (unixfsOpts) ResolveSize(resolve bool) UnixfsLsOption {
317 return func(settings *UnixfsLsSettings) error {
318 settings.ResolveSize = resolve
core/coreiface/tests/unixfs.go
+1 -20
@@ -749,7 +749,7 @@ func (tp *provider) TestLs(t *testing.T) {
749 t.Error(err)
750 }
751
752 - links, err := api.Unixfs().Ls(ctx, p, options.Unixfs.Async(false))
752 + links, err := api.Unixfs().Ls(ctx, p)
753 if err != nil {
754 t.Error(err)
755 }
@@ -767,25 +767,6 @@ func (tp *provider) TestLs(t *testing.T) {
767 if _, ok := <-links; ok {
768 t.Errorf("didn't expect a second link")
769 }
770 -
771 - links, err = api.Unixfs().Ls(ctx, p, options.Unixfs.Async(true))
772 - if err != nil {
773 - t.Error(err)
774 - }
775 -
776 - link = (<-links).Link
777 - if link.Size != 23 {
778 - t.Fatalf("expected size = 23, got %d", link.Size)
779 - }
780 - if link.Name != "name-of-file" {
781 - t.Fatalf("expected name = name-of-file, got %s", link.Name)
782 - }
783 - if link.Cid.String() != "QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr" {
784 - t.Fatalf("expected cid = QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr, got %s", link.Cid)
785 - }
786 - if _, ok := <-links; ok {
787 - t.Errorf("didn't expect a second link")
788 - }
770 }
771
772 func (tp *provider) TestEntriesExpired(t *testing.T) {
core/coreiface/unixfs.go
+2 -1
@@ -38,6 +38,7 @@ type UnixfsAPI interface {
38 // to operations performed on the returned file
39 Get(context.Context, Path) (files.Node, error)
40
41 - // Ls returns the list of links in a directory
41 + // Ls returns the list of links in a directory. Links aren't guaranteed to be
42 + // returned in order
43 Ls(context.Context, Path, ...options.UnixfsLsOption) (<-chan LsLink, error)
44 }