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

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JonKrone committed Mar 15, 2018
1 parent a1aa90a commit 661c4bf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/cli/commands/files/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ module.exports = {
alias: 'n',
type: 'boolean',
default: false,
describe: 'Only chunk and hash, do not write to disk'
describe: 'Only chunk and hash, do not write'
},
'enable-sharding-experiment': {
type: 'boolean',
Expand Down
2 changes: 1 addition & 1 deletion src/http/api/resources/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ exports.add = {
'cid-version': request.query['cid-version'],
'raw-leaves': request.query['raw-leaves'],
progress: request.query.progress ? progressHandler : null,
onlyHash: !!request.query['only-hash']
onlyHash: Boolean(request.query['only-hash'])
}

const aborter = abortable()
Expand Down
11 changes: 7 additions & 4 deletions test/cli/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,14 @@ describe('files', () => runOnAndOff((thing) => {
fs.writeFileSync(filepath, content)

return ipfs(`files add --only-hash ${filepath}`)
.then(hash => {
const speculativeHash = hash.split(' ')[1]
.then(out => {
const hash = out.split(' ')[1]

// 'jsipfs object get <hash>' should time out with the daemon on
// and should fail fast with the daemon off
return Promise.race([
ipfs.fail(`object get ${speculativeHash}`),
new Promise(res => setTimeout(res, 5000))
ipfs.fail(`object get ${hash}`),
new Promise((resolve, reject) => setTimeout(resolve, 4000))
])
.then(() => fs.unlinkSync(filepath))
})
Expand Down
7 changes: 3 additions & 4 deletions test/http-api/extra/files.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

module.exports = ctl => {
Expand All @@ -12,8 +12,7 @@ module.exports = ctl => {
it('performs a speculative add, --only-hash', () => {
const content = String(Math.random() + Date.now())

return ctl
.add(Buffer.from(content), { onlyHash: true })
return ctl.add(Buffer.from(content), { onlyHash: true })
.then(files => {
const getAttempt = ctl.object.get(files[0].hash)
.then(() => {
Expand All @@ -22,7 +21,7 @@ module.exports = ctl => {

return Promise.race([
getAttempt,
new Promise(res => setTimeout(res, 4000))
new Promise((resolve, reject) => setTimeout(resolve, 4000))
])
})
})
Expand Down

0 comments on commit 661c4bf

Please sign in to comment.