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

Commit

Permalink
feat(init): add empty unixfs dir to match go-ipfs
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Dec 12, 2016
1 parent 9058118 commit a967bb0
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/core/components/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const peerId = require('peer-id')
const waterfall = require('async/waterfall')
const parallel = require('async/parallel')

const addDefaultAssets = require('./init-assets')

Expand Down Expand Up @@ -51,11 +52,28 @@ module.exports = function init (self) {
},
(cb) => self._repo.config.set(config, cb),
(cb) => {
if (typeof addDefaultAssets === 'function' && !opts.emptyRepo) {
return addDefaultAssets(self, opts.log, cb)
if (opts.emptyRepo) {
return cb(null, true)
}

cb(null, true)
const tasks = [
// add empty unixfs dir object (go-ipfs assumes this exists)
(cb) => self.object.new('unixfs-dir', cb)
]

if (typeof addDefaultAssets === 'function') {
tasks.push(
(cb) => addDefaultAssets(self, opts.log, cb)
)
}

parallel(tasks, (err) => {
if (err) {
return cb(err)
}

cb(null, true)
})
}
], callback)
}
Expand Down

0 comments on commit a967bb0

Please sign in to comment.