ipfs-shipyard / ipfs-blob-store

An abstract-blob-store compatible implementation built using IPFS as the storage backend
MIT License
56 stars 8 forks source link

file not available when writestream ends #11

Open hackergrrl opened 8 years ago

hackergrrl commented 8 years ago

File not found by the time the stream ends. (Using the cb param on createWriteStream works though)

var ws = store.createWriteStream({
  key: 'cookso'
})

ws.write('hello world\n')
ws.end(function () {
  var rs = store.createReadStream({
    key: 'cookso'
  })

  rs.pipe(process.stdout)
})
daviddias commented 8 years ago

the streams gets buffered and then sent through js-ipfs-api, which causes your callback to fire while the request is being made, causing a racing condition with your read. Makes sense?

dignifiedquire commented 8 years ago

This is the same issue we had with idb-blob-store. You can see a solution to this in idb-plus-blob-store.

hackergrrl commented 8 years ago

@diasdavid: You mean go-ipfs is closing the stream before flushing? That HTTP request to go-ipfs shouldn't be closing until it's flushed it to disk.

@dignifiedquire: I think this might be something different? Do you have a write-up on that?