Commit 97fb3e4d authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi unixfs: filestore opts

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent df179711
......@@ -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
}
}
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