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

feat: allow controlling preload behaviour from cli #2384

Merged
merged 3 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cli/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ module.exports = {
type: 'boolean',
default: true,
describe: 'Pin this object when adding'
},
preload: {
type: 'boolean',
default: true,
describe: 'Preload this object when adding'
}
},

Expand All @@ -166,7 +171,8 @@ module.exports = {
hashAlg: argv.hash,
wrapWithDirectory: argv.wrapWithDirectory,
pin: argv.pin,
chunker: argv.chunker
chunker: argv.chunker,
preload: argv.preload
}

if (options.enableShardingExperiment && argv.isDaemonOn()) {
Expand Down
6 changes: 4 additions & 2 deletions src/http/api/resources/files-regular.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ exports.add = {
pin: Joi.boolean().default(true),
'wrap-with-directory': Joi.boolean(),
chunker: Joi.string(),
trickle: Joi.boolean()
trickle: Joi.boolean(),
preload: Joi.boolean().default(true)
})
// TODO: Necessary until validate "recursive", "stream-channels" etc.
.options({ allowUnknown: true })
Expand Down Expand Up @@ -220,7 +221,8 @@ exports.add = {
wrapWithDirectory: request.query['wrap-with-directory'],
pin: request.query.pin,
chunker: request.query.chunker,
strategy: request.query.trickle ? 'trickle' : 'balanced'
strategy: request.query.trickle ? 'trickle' : 'balanced',
preload: request.query.preload
}

const aborter = abortable()
Expand Down
8 changes: 7 additions & 1 deletion test/http-api/inject/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ module.exports = (http) => {
expect(res.result).to.have.property('Path')
})

it('resolve ipfs.enstest.eth ENS', async () => {
it('resolve ipfs.enstest.eth ENS', async function () {
const res = await api.inject({
method: 'GET',
url: '/api/v0/dns?arg=ipfs.enstest.eth'
})

// TODO: eth.link domains have no SLA yet and are liable to be down...
// Remove skip when reliable!
if (res.statusCode === 500) {
return this.skip()
}

expect(res.result).to.have.property('Path')
})
})
Expand Down