Skip to content

No longer considers a non-existant repo an error. #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 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
17 changes: 10 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ exports = module.exports = Repo

function Repo (repoPath, options) {
this.init = (config, callback) => {
if (this.exists()) {
throw new Error('Repo already exists')
}
this.exists((err, exists) => {
if (err) { throw err }
if (exists) { throw new Error('Repo already exists') }
throw new Error('not implemented')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'not implemented' or 'repo not found'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no further implementation of repo.init yet, so 'not implemented' seemed fitting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it! :)

})
}

this.locks = stores
.locks
.setUp(repoPath, options.stores.locks)

this.exists = callback => {
this.version.get((err, version) => {
this.exists = (callback) => {
this.version.exists((err, exists) => {
if (err) {
return callback(new Error('Repo does not exist'))
callback(new Error('repo does not exist'), false)
} else {
callback(null, exists)
}
callback(null, true)
})
}

Expand Down
3 changes: 3 additions & 0 deletions src/stores/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ exports.setUp = (basePath, blobStore, locks) => {
var store = blobStore(basePath)

return {
exists: callback => {
store.exists('version', callback)
},
get: callback => {
store
.createReadStream('version')
Expand Down
2 changes: 1 addition & 1 deletion tests/node-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const rimraf = require('rimraf')

const IPFSRepo = require('../src')

describe('IPFS Repo Testson on Node.js', () => {
describe('IPFS Repo Tests on on Node.js', () => {
const testRepoPath = __dirname + '/test-repo'
const date = Date.now().toString()
const repoPath = testRepoPath + date
Expand Down