@cryptotaxi247 / kubo / commits / ac8ff3073

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@8521907e1a8ac009252669ad3e40be2d93438ad3 This commit was moved from ipfs/boxo@27ded0dea2d8b2ee4c115c9cd40c2d1514927162

Łukasz Magiera committed Sep 20, 2018 at 23:05 UTC ac8ff307329da34110495b69df9c003232f78c81
1 file changed +29
core/coreiface/options/unixfs.go
+29
@@ -21,6 +21,10 @@ type UnixfsAddSettings struct {
21
22 Chunker string
23 Layout Layout
24 +
25 + Pin bool
26 + OnlyHash bool
27 + Local bool
28 }
29
30 type UnixfsAddOption func(*UnixfsAddSettings) error
@@ -36,6 +40,10 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, error) {
40
41 Chunker: "size-262144",
42 Layout: BalancedLayout,
43 +
44 + Pin: false,
45 + OnlyHash: false,
46 + Local: false,
47 }
48
49 for _, opt := range opts {
@@ -94,3 +102,24 @@ func (unixfsOpts) Layout(layout Layout) UnixfsAddOption {
102 return nil
103 }
104 }
105 +
106 +func (unixfsOpts) Pin(pin bool) UnixfsAddOption {
107 + return func(settings *UnixfsAddSettings) error {
108 + settings.Pin = pin
109 + return nil
110 + }
111 +}
112 +
113 +func (unixfsOpts) HashOnly(hashOnly bool) UnixfsAddOption {
114 + return func(settings *UnixfsAddSettings) error {
115 + settings.OnlyHash = hashOnly
116 + return nil
117 + }
118 +}
119 +
120 +func (unixfsOpts) Local(local bool) UnixfsAddOption {
121 + return func(settings *UnixfsAddSettings) error {
122 + settings.Local = local
123 + return nil
124 + }
125 +}