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

removes --force #97

Merged
merged 1 commit into from
Apr 2, 2016
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
2 changes: 1 addition & 1 deletion src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function IPFS (repo) {
}

this.repo = {
init: (bits, force, empty, callback) => {
init: (bits, empty, callback) => {
// 1. check if repo already exists
},

Expand Down
7 changes: 3 additions & 4 deletions src/core/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ const path = require('path')

module.exports = (repo, opts, callback) => {
opts = opts || {}
opts.force = opts.force || false
opts.emptyRepo = opts.emptyRepo || false
opts.bits = opts.bits || 2048

// Pre-set config values.
var config = require('../init-files/default-config.json')

// Verify repo does not yet exist (or that 'force' is provided).
// Verify repo does not yet exist.
repo.exists((err, res) => {
if (err) { return callback(err) }
if (res === true && !opts.force) {
return callback(new Error('repo already exists and \'force\' is not set'))
if (res === true) {
return callback(new Error('repo already exists'))
}

generateAndSetKeypair()
Expand Down
19 changes: 0 additions & 19 deletions test/core-tests/test-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,4 @@ describe('init', function () {
})
})
})

it('force init (overwrite)', (done) => {
var repo = createTempRepo()
const ipfs1 = new IPFS(repo)
const ipfs2 = new IPFS(repo)
ipfs1.init({ bits: 128, emptyRepo: true }, (err) => {
expect(err).to.not.exist

ipfs2.init({ bits: 128, force: false }, (err) => {
expect(err).to.exist

ipfs2.init({ force: true }, (err) => {
expect(err).to.not.exist

repo.teardown(done)
})
})
})
})
})