Skip to content

Commit

Permalink
feat: Update deps and fix tests (#20)
Browse files Browse the repository at this point in the history
* fix: update deps and start reviewing the code

* update nodejs ver

* Update readme badges

* fix test
  • Loading branch information
hacdias authored and daviddias committed Jan 25, 2018
1 parent 022c443 commit 8d81bd4
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
npm-debug.log
yarn.lock
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '4'
- '8'

# Make sure we have new NPM.
before_install:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ipfs-blob-store

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
![Build Status](https://travis-ci.org/ipfs/ipfs-blob-store.svg?style=flat-square)](https://travis-ci.org/ipfs/ipfs-blob-store)
[![Build Status](https://travis-ci.org/ipfs-shipyard/ipfs-blob-store.svg?style=flat-square)](https://travis-ci.org/ipfs-shipyard/ipfs-blob-store)
![](https://img.shields.io/badge/coverage-%3F-yellow.svg?style=flat-square)
[![Dependency Status](https://david-dm.org/ipfs/ipfs-blob-store.svg?style=flat-square)](https://david-dm.org/ipfs/ipfs-blob-store)
[![Dependency Status](https://david-dm.org/ipfs-shipyard/ipfs-blob-store.svg?style=flat-square)](https://david-dm.org/ipfs-shipyard/ipfs-blob-store)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

> An abstract-blob-store compatible implementation built using IPFS as the storage backend
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@
},
"homepage": "https://github.com/ipfs/ipfs-blob-store",
"devDependencies": {
"abstract-blob-store": "^3.2.0",
"ipfsd-ctl": "^0.16.0",
"pre-commit": "^1.1.3",
"tape": "^4.6.2"
"abstract-blob-store": "^3.3.2",
"go-ipfs-dep": "^0.4.13",
"ipfsd-ctl": "^0.27.1",
"pre-commit": "^1.2.2",
"tape": "^4.8.0"
},
"pre-commit": [
"test",
"lint"
],
"dependencies": {
"ipfs-api": "9.0.0"
"ipfs-api": "17.5.0"
}
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var ipfsAPI = require('ipfs-api')
var mfs = require('./mfs')
const ipfsAPI = require('ipfs-api')
const mfs = require('./mfs')

module.exports = function (options) {
if (!options) options = {}
Expand Down
17 changes: 9 additions & 8 deletions src/mfs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var stream = require('stream')
const stream = require('stream')

module.exports = function (options) {
var store = {}
Expand Down Expand Up @@ -69,8 +69,12 @@ module.exports = function (options) {

var passThrough = new stream.PassThrough()

ipfsCtl.files.read(store.baseDir + opts.key, {}, function (err, stream) {
ipfsCtl.files.read(store.baseDir + opts.key, {}, (err, stream) => {
if (err) {
if (err.toString().indexOf('does not exist') > -1) {
err.notFound = true
}

return passThrough.emit('error', err)
}

Expand All @@ -85,7 +89,7 @@ module.exports = function (options) {
if (opts.name) opts.key = opts.name
if (!cb) cb = noop

ipfsCtl.files.stat(store.baseDir + opts.key, {}, function (err, res) {
ipfsCtl.files.stat(store.baseDir + opts.key, {}, (err, res) => {
if (err) {
if (err.code === 0) {
return cb(null, false)
Expand All @@ -102,12 +106,9 @@ module.exports = function (options) {
if (opts.name) opts.key = opts.name
if (!cb) cb = noop

ipfsCtl.files.rm(store.baseDir + opts.key, {}, function (err) {
ipfsCtl.files.rm(store.baseDir + opts.key, {}, (err) => {
if (err) {
// console.log('error ->', err)
return cb()
// TODO files API is responding with 500 (probably cause of bitswap)
// return cb(err)
return cb(err)
}

cb()
Expand Down
37 changes: 17 additions & 20 deletions tests/blob-store-test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
var test = require('tape')
var abstractBlobTests = require('abstract-blob-store/tests')
var ipfsBlobStore = require('../src')
var ipfsd = require('ipfsd-ctl')
const test = require('tape')
const abstractBlobTests = require('abstract-blob-store/tests')
const ipfsBlobStore = require('../src')
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

ipfsd.disposable({
apiAddr: '/ip4/127.0.0.1/tcp/13000',
init: true
df.spawn({
disposable: true,
args: ['--api=/ip4/127.0.0.1/tcp/13000']
}, (err, node) => {
if (err) {
throw err
}
node.startDaemon((err) => {
if (err) {
throw err
}
abstractBlobTests(test, common)
// quick hack to stop the deamon
// TODO clean up later
setTimeout(function () {
node.stopDaemon(() => {})
}, 5000)
})

abstractBlobTests(test, common)
// quick hack to stop the deamon
// TODO clean up later
setTimeout(function () {
node.stop(() => {})
}, 5000)
})

var common = {
Expand All @@ -31,15 +28,15 @@ var common = {
}
var store = ipfsBlobStore(options)

store.ipfsCtl.files.mkdir(options.baseDir, { p: true }, function (err) {
store.ipfsCtl.files.mkdir(options.baseDir, { p: true }, (err) => {
if (err) {
return console.error(err)
}
cb(null, store)
})
},
teardown: function (t, store, blob, cb) {
store.ipfsCtl.files.rm(store.baseDir, { 'recursive': true }, function (err) {
store.ipfsCtl.files.rm(store.baseDir, { recursive: true }, (err) => {
if (err) {
return cb(err)
}
Expand Down

0 comments on commit 8d81bd4

Please sign in to comment.