Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

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>
  • Loading branch information
magik6k committed Oct 3, 2018
1 parent ee22ac4 commit 8521907
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 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 8521907

Please sign in to comment.