@@ -10,6 +10,7 @@ const zip = require('pull-zip')
10
10
const getFolderSize = require ( 'get-folder-size' )
11
11
const byteman = require ( 'byteman' )
12
12
const waterfall = require ( 'async/waterfall' )
13
+ const mh = require ( 'multihashes' )
13
14
const utils = require ( '../../utils' )
14
15
const print = require ( '../../utils' ) . print
15
16
const createProgressBar = require ( '../../utils' ) . createProgressBar
@@ -162,6 +163,11 @@ module.exports = {
162
163
type : 'integer' ,
163
164
describe : 'Cid version. Non-zero value will change default of \'raw-leaves\' to true. (experimental)'
164
165
} ,
166
+ hash : {
167
+ type : 'string' ,
168
+ choices : Object . keys ( mh . names ) ,
169
+ describe : 'Hash function to use. Will set Cid version to 1 if used. (experimental)'
170
+ } ,
165
171
quiet : {
166
172
alias : 'q' ,
167
173
type : 'boolean' ,
@@ -191,7 +197,8 @@ module.exports = {
191
197
: Infinity ,
192
198
cidVersion : argv . cidVersion ,
193
199
rawLeaves : argv . rawLeaves ,
194
- onlyHash : argv . onlyHash
200
+ onlyHash : argv . onlyHash ,
201
+ hashAlg : argv . hash
195
202
}
196
203
197
204
// Temporary restriction on raw-leaves:
@@ -206,6 +213,18 @@ module.exports = {
206
213
throw new Error ( 'Implied argument raw-leaves must be passed and set to false when cid-version is > 0' )
207
214
}
208
215
216
+ // Temporary restriction on raw-leaves:
217
+ // When hash != undefined then raw-leaves MUST be present and false.
218
+ //
219
+ // This is because raw-leaves is not yet implemented in js-ipfs,
220
+ // and go-ipfs changes the value of raw-leaves to true when
221
+ // hash != undefined unless explicitly set to false.
222
+ //
223
+ // This retains feature parity without having to implement raw-leaves.
224
+ if ( options . hash && options . rawLeaves !== false ) {
225
+ throw new Error ( 'Implied argument raw-leaves must be passed and set to false when hash argument is specified' )
226
+ }
227
+
209
228
if ( options . rawLeaves ) {
210
229
throw new Error ( 'Not implemented: raw-leaves' )
211
230
}
0 commit comments