Commit 01bbf29c authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi: resolve type/size in Unixfs.Ls

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent 72006bfe
......@@ -44,6 +44,9 @@ type UnixfsAddSettings struct {
type UnixfsLsSettings struct {
Async bool
ResolveType bool
ResolveSize bool
}
type UnixfsAddOption func(*UnixfsAddSettings) error
......@@ -320,3 +323,17 @@ func (unixfsOpts) Async(async bool) UnixfsLsOption {
return nil
}
}
func (unixfsOpts) ResolveSize(resolve bool) UnixfsLsOption {
return func(settings *UnixfsLsSettings) error {
settings.ResolveSize = resolve
return nil
}
}
func (unixfsOpts) ResolveType(resolve bool) UnixfsLsOption {
return func(settings *UnixfsLsSettings) error {
settings.ResolveSize = resolve
return nil
}
}
\ No newline at end of file
......@@ -2,10 +2,10 @@ package iface
import (
"context"
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
ft "gx/ipfs/QmQ1JnYpnzkaurjW1yxkQxC2w3K1PorNE1nv1vaP5Le7sq/go-unixfs"
"gx/ipfs/QmQ1JnYpnzkaurjW1yxkQxC2w3K1PorNE1nv1vaP5Le7sq/go-unixfs/pb"
ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format"
"gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files"
)
......@@ -16,6 +16,14 @@ type AddEvent struct {
Size string `json:",omitempty"`
}
type LsLink struct {
Link *ipld.Link
Size uint64
Type unixfs_pb.Data_DataType
Err error
}
// UnixfsAPI is the basic interface to immutable files in IPFS
// NOTE: This API is heavily WIP, things are guaranteed to break frequently
type UnixfsAPI interface {
......@@ -31,5 +39,5 @@ type UnixfsAPI interface {
Get(context.Context, Path) (files.Node, error)
// Ls returns the list of links in a directory
Ls(context.Context, Path, ...options.UnixfsLsOption) (<-chan ft.LinkResult, error)
Ls(context.Context, Path, ...options.UnixfsLsOption) (<-chan LsLink, error)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment