Skip to content

Commit

Permalink
fix: add validation of dir-wrapped ipfs.files.add
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed May 18, 2018
1 parent 866718f commit 45ccfca
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,13 @@ module.exports = async function init () {
},

async ipfsAddAndShow (data, options) {
options = options || {}
let result
try {
result = await api.ipfs.files.add(data, options)
if (options.wrapWithDirectory && result.length !== data.length + 1) {
throw new Error(`ipfs.files.add result should include an entry for every uploaded file plus additional one for a wrapping directory (${data.length + 1} in total), but found only ${result.length} entries`)
}
} catch (err) {
console.error('Failed to IPFS add', err)
notify('notify_uploadErrorTitle', 'notify_inlineErrorMsg', `${err.message}`)
Expand Down

0 comments on commit 45ccfca

Please sign in to comment.