Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11 from ipfs/fix/error
Browse files Browse the repository at this point in the history
fix(block-service): return errors for addBlock
  • Loading branch information
daviddias committed Apr 23, 2016
2 parents d3e6baf + 0fea48d commit 2cf6f1f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/block-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@ const async = require('async')
function BlockService (ipfsRepo, exchange) {
this.addBlock = (block, callback) => {
const ws = ipfsRepo.datastore.createWriteStream(block.key, block.extension)

let done = false

ws.write(block.data)
ws.once('finish', callback)
ws.once('error', (err) => {
done = true
callback(err)
})
ws.once('finish', () => {
if (!done) callback()
})
ws.end()
}

Expand Down

0 comments on commit 2cf6f1f

Please sign in to comment.