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
df179711
Commit
df179711
authored
Oct 04, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi unixfs: progress events
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
aa7a8776
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
options/unixfs.go
options/unixfs.go
+35
-0
unixfs.go
unixfs.go
+9
-0
No files found.
options/unixfs.go
View file @
df179711
...
@@ -35,6 +35,10 @@ type UnixfsAddSettings struct {
...
@@ -35,6 +35,10 @@ type UnixfsAddSettings struct {
Wrap
bool
Wrap
bool
Hidden
bool
Hidden
bool
StdinName
string
StdinName
string
Events
chan
<-
interface
{}
Silent
bool
Progress
bool
}
}
type
UnixfsAddOption
func
(
*
UnixfsAddSettings
)
error
type
UnixfsAddOption
func
(
*
UnixfsAddSettings
)
error
...
@@ -59,6 +63,10 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix,
...
@@ -59,6 +63,10 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix,
Wrap
:
false
,
Wrap
:
false
,
Hidden
:
false
,
Hidden
:
false
,
StdinName
:
""
,
StdinName
:
""
,
Events
:
nil
,
Silent
:
false
,
Progress
:
false
,
}
}
for
_
,
opt
:=
range
opts
{
for
_
,
opt
:=
range
opts
{
...
@@ -236,3 +244,30 @@ func (unixfsOpts) StdinName(name string) UnixfsAddOption {
...
@@ -236,3 +244,30 @@ func (unixfsOpts) StdinName(name string) UnixfsAddOption {
return
nil
return
nil
}
}
}
}
// Events specifies channel which will be used to report events about ongoing
// Add operation.
//
// Note that if this channel blocks it may slowdown the adder
func
(
unixfsOpts
)
Events
(
sink
chan
<-
interface
{})
UnixfsAddOption
{
return
func
(
settings
*
UnixfsAddSettings
)
error
{
settings
.
Events
=
sink
return
nil
}
}
// Silent reduces event output
func
(
unixfsOpts
)
Silent
(
silent
bool
)
UnixfsAddOption
{
return
func
(
settings
*
UnixfsAddSettings
)
error
{
settings
.
Silent
=
silent
return
nil
}
}
// Progress tells the adder whether to enable progress events
func
(
unixfsOpts
)
Progress
(
enable
bool
)
UnixfsAddOption
{
return
func
(
settings
*
UnixfsAddSettings
)
error
{
settings
.
Progress
=
enable
return
nil
}
}
unixfs.go
View file @
df179711
...
@@ -9,6 +9,14 @@ import (
...
@@ -9,6 +9,14 @@ import (
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
)
)
// TODO: ideas on making this more coreapi-ish without breaking the http API?
type
AddEvent
struct
{
Name
string
Hash
string
`json:",omitempty"`
Bytes
int64
`json:",omitempty"`
Size
string
`json:",omitempty"`
}
// UnixfsAPI is the basic interface to immutable files in IPFS
// UnixfsAPI is the basic interface to immutable files in IPFS
// NOTE: This API is heavily WIP, things are guaranteed to break frequently
// NOTE: This API is heavily WIP, things are guaranteed to break frequently
type
UnixfsAPI
interface
{
type
UnixfsAPI
interface
{
...
@@ -24,6 +32,7 @@ type UnixfsAPI interface {
...
@@ -24,6 +32,7 @@ type UnixfsAPI interface {
Get
(
context
.
Context
,
Path
)
(
files
.
File
,
error
)
Get
(
context
.
Context
,
Path
)
(
files
.
File
,
error
)
// Cat returns a reader for the file
// Cat returns a reader for the file
// TODO: Remove in favour of Get (if we use Get on a file we still have reader directly, so..)
Cat
(
context
.
Context
,
Path
)
(
Reader
,
error
)
Cat
(
context
.
Context
,
Path
)
(
Reader
,
error
)
// Ls returns the list of links in a directory
// Ls returns the list of links in a directory
...
...
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