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
97fb3e4d
Commit
97fb3e4d
authored
Oct 04, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi unixfs: filestore opts
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
df179711
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
options/unixfs.go
options/unixfs.go
+35
-0
No files found.
options/unixfs.go
View file @
97fb3e4d
...
...
@@ -31,6 +31,8 @@ type UnixfsAddSettings struct {
Pin
bool
OnlyHash
bool
Local
bool
FsCache
bool
NoCopy
bool
Wrap
bool
Hidden
bool
...
...
@@ -59,6 +61,8 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix,
Pin
:
false
,
OnlyHash
:
false
,
Local
:
false
,
FsCache
:
false
,
NoCopy
:
false
,
Wrap
:
false
,
Hidden
:
false
,
...
...
@@ -76,6 +80,17 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix,
}
}
// nocopy -> rawblocks
if
options
.
NoCopy
&&
!
options
.
RawLeaves
{
// fixed?
if
options
.
RawLeavesSet
{
return
nil
,
cid
.
Prefix
{},
fmt
.
Errorf
(
"nocopy option requires '--raw-leaves' to be enabled as well"
)
}
// No, satisfy mandatory constraint.
options
.
RawLeaves
=
true
}
// (hash != "sha2-256") -> CIDv1
if
options
.
MhType
!=
mh
.
SHA2_256
{
switch
options
.
CidVersion
{
...
...
@@ -271,3 +286,23 @@ func (unixfsOpts) Progress(enable bool) UnixfsAddOption {
return
nil
}
}
// FsCache tells the adder to check the filestore for pre-existing blocks
//
// Experimental
func
(
unixfsOpts
)
FsCache
(
enable
bool
)
UnixfsAddOption
{
return
func
(
settings
*
UnixfsAddSettings
)
error
{
settings
.
FsCache
=
enable
return
nil
}
}
// NoCopy tells the adder to add the files using filestore. Implies RawLeaves.
//
// Experimental
func
(
unixfsOpts
)
Nocopy
(
enable
bool
)
UnixfsAddOption
{
return
func
(
settings
*
UnixfsAddSettings
)
error
{
settings
.
NoCopy
=
enable
return
nil
}
}
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