Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
a62acc82
Commit
a62acc82
authored
Feb 02, 2019
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi: stream only ls, handle storting in command
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
fad4bd39
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
35 deletions
+3
-35
options/unixfs.go
options/unixfs.go
+0
-14
tests/unixfs.go
tests/unixfs.go
+1
-20
unixfs.go
unixfs.go
+2
-1
No files found.
options/unixfs.go
View file @
a62acc82
...
...
@@ -43,8 +43,6 @@ type UnixfsAddSettings struct {
}
type
UnixfsLsSettings
struct
{
Async
bool
ResolveType
bool
ResolveSize
bool
}
...
...
@@ -132,8 +130,6 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix,
func
UnixfsLsOptions
(
opts
...
UnixfsLsOption
)
(
*
UnixfsLsSettings
,
error
)
{
options
:=
&
UnixfsLsSettings
{
Async
:
true
,
ResolveSize
:
true
,
ResolveType
:
true
,
}
...
...
@@ -317,16 +313,6 @@ func (unixfsOpts) Nocopy(enable bool) UnixfsAddOption {
}
}
// Async tells ls to return results as soon as they are available, which can be
// useful for listing HAMT directories. When this option is set to true returned
// results won't be returned in order
func
(
unixfsOpts
)
Async
(
async
bool
)
UnixfsLsOption
{
return
func
(
settings
*
UnixfsLsSettings
)
error
{
settings
.
Async
=
async
return
nil
}
}
func
(
unixfsOpts
)
ResolveSize
(
resolve
bool
)
UnixfsLsOption
{
return
func
(
settings
*
UnixfsLsSettings
)
error
{
settings
.
ResolveSize
=
resolve
...
...
tests/unixfs.go
View file @
a62acc82
...
...
@@ -749,7 +749,7 @@ func (tp *provider) TestLs(t *testing.T) {
t
.
Error
(
err
)
}
links
,
err
:=
api
.
Unixfs
()
.
Ls
(
ctx
,
p
,
options
.
Unixfs
.
Async
(
false
)
)
links
,
err
:=
api
.
Unixfs
()
.
Ls
(
ctx
,
p
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -767,25 +767,6 @@ func (tp *provider) TestLs(t *testing.T) {
if
_
,
ok
:=
<-
links
;
ok
{
t
.
Errorf
(
"didn't expect a second link"
)
}
links
,
err
=
api
.
Unixfs
()
.
Ls
(
ctx
,
p
,
options
.
Unixfs
.
Async
(
true
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
link
=
(
<-
links
)
.
Link
if
link
.
Size
!=
23
{
t
.
Fatalf
(
"expected size = 23, got %d"
,
link
.
Size
)
}
if
link
.
Name
!=
"name-of-file"
{
t
.
Fatalf
(
"expected name = name-of-file, got %s"
,
link
.
Name
)
}
if
link
.
Cid
.
String
()
!=
"QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr"
{
t
.
Fatalf
(
"expected cid = QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr, got %s"
,
link
.
Cid
)
}
if
_
,
ok
:=
<-
links
;
ok
{
t
.
Errorf
(
"didn't expect a second link"
)
}
}
func
(
tp
*
provider
)
TestEntriesExpired
(
t
*
testing
.
T
)
{
...
...
unixfs.go
View file @
a62acc82
...
...
@@ -38,6 +38,7 @@ type UnixfsAPI interface {
// to operations performed on the returned file
Get
(
context
.
Context
,
Path
)
(
files
.
Node
,
error
)
// Ls returns the list of links in a directory
// Ls returns the list of links in a directory. Links aren't guaranteed to be
// returned in order
Ls
(
context
.
Context
,
Path
,
...
options
.
UnixfsLsOption
)
(
<-
chan
LsLink
,
error
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment