Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit a01f5b6

Browse files
authored
fix: add default args for ipfs.add (#2950)
So we don't send invalid args over http.
1 parent 8c97de1 commit a01f5b6

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

packages/ipfs-http-client/src/lib/to-url-search-params.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const mtimeToObject = require('./mtime-to-object')
66
module.exports = (args, options) => {
77
const searchParams = new URLSearchParams(options)
88

9-
if (args === undefined) {
9+
if (args === undefined || args === null) {
1010
args = []
1111
} else if (!Array.isArray(args)) {
1212
args = [args]

packages/ipfs/src/cli/commands/add.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ module.exports = {
7474
},
7575
'raw-leaves': {
7676
type: 'boolean',
77-
describe: 'Use raw blocks for leaf nodes. (experimental)'
77+
describe: 'Use raw blocks for leaf nodes. (experimental)',
78+
default: false
7879
},
7980
'cid-version': {
8081
type: 'integer',
@@ -89,7 +90,8 @@ module.exports = {
8990
hash: {
9091
type: 'string',
9192
choices: Object.keys(mh.names),
92-
describe: 'Hash function to use. Will set CID version to 1 if used. (experimental)'
93+
describe: 'Hash function to use. Will set CID version to 1 if used. (experimental)',
94+
default: 'sha2-256'
9395
},
9496
quiet: {
9597
alias: 'q',
@@ -174,9 +176,7 @@ module.exports = {
174176
const { ipfs, print, isDaemon, getStdin } = argv.ctx
175177
const options = {
176178
trickle: argv.trickle,
177-
shardSplitThreshold: argv.enableShardingExperiment
178-
? argv.shardSplitThreshold
179-
: Infinity,
179+
shardSplitThreshold: argv.shardSplitThreshold,
180180
cidVersion: argv.cidVersion,
181181
rawLeaves: argv.rawLeaves,
182182
onlyHash: argv.onlyHash,
@@ -185,7 +185,6 @@ module.exports = {
185185
pin: argv.pin,
186186
chunker: argv.chunker,
187187
preload: argv.preload,
188-
nonatomic: argv.nonatomic,
189188
fileImportConcurrency: argv.fileImportConcurrency,
190189
blockWriteConcurrency: argv.blockWriteConcurrency,
191190
progress: () => {}

packages/ipfs/test/cli/files-regular.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ const HASH_ALGS = [
2525
function defaultAddArgs (overrides) {
2626
return {
2727
trickle: false,
28-
shardSplitThreshold: Infinity,
28+
shardSplitThreshold: 1000,
2929
cidVersion: 0,
30-
rawLeaves: undefined,
30+
rawLeaves: false,
3131
onlyHash: false,
32-
hashAlg: undefined,
32+
hashAlg: 'sha2-256',
3333
wrapWithDirectory: false,
3434
pin: true,
3535
chunker: 'size-262144',
3636
preload: true,
37-
nonatomic: undefined,
3837
fileImportConcurrency: 50,
3938
blockWriteConcurrency: 10,
4039
progress: sinon.match.func,

0 commit comments

Comments
 (0)