mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-01 06:17:56 +08:00
coreapi unixfs: pin/local/hash-only options
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@8521907e1a This commit was moved from ipfs/boxo@27ded0dea2
This commit is contained in:
parent
82ef32dcaf
commit
ac8ff30732
@ -21,6 +21,10 @@ type UnixfsAddSettings struct {
|
||||
|
||||
Chunker string
|
||||
Layout Layout
|
||||
|
||||
Pin bool
|
||||
OnlyHash bool
|
||||
Local bool
|
||||
}
|
||||
|
||||
type UnixfsAddOption func(*UnixfsAddSettings) error
|
||||
@ -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 {
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user