Skip to content

Commit

Permalink
coreapi unixfs: pin/local/hash-only options
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>


This commit was moved from ipfs/interface-go-ipfs-core@8521907
  • Loading branch information
magik6k committed Oct 3, 2018
1 parent f858a52 commit 27ded0d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions coreiface/options/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ type UnixfsAddSettings struct {

Chunker string
Layout Layout

Pin bool
OnlyHash bool
Local bool
}

type UnixfsAddOption func(*UnixfsAddSettings) error
Expand All @@ -36,6 +40,10 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, error) {

Chunker: "size-262144",
Layout: BalancedLayout,

Pin: false,
OnlyHash: false,
Local: false,
}

for _, opt := range opts {
Expand Down Expand Up @@ -94,3 +102,24 @@ func (unixfsOpts) Layout(layout Layout) UnixfsAddOption {
return nil
}
}

func (unixfsOpts) Pin(pin bool) UnixfsAddOption {
return func(settings *UnixfsAddSettings) error {
settings.Pin = pin
return nil
}
}

func (unixfsOpts) HashOnly(hashOnly bool) UnixfsAddOption {
return func(settings *UnixfsAddSettings) error {
settings.OnlyHash = hashOnly
return nil
}
}

func (unixfsOpts) Local(local bool) UnixfsAddOption {
return func(settings *UnixfsAddSettings) error {
settings.Local = local
return nil
}
}

0 comments on commit 27ded0d

Please sign in to comment.