git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit 05823d6d7c289c51a49c2d0eb8911e4df09bdfca

UGLY HACK so that sbot_blobs_add calls back after write has succeeded

Dominic Tarr committed on 7/24/2016, 1:08:39 AM
Parent: f472c56537886044c04798db5a6d9b631285d1ac

Files changed

sbot-api.jschanged
sbot-api.jsView
@@ -68,9 +68,22 @@
6868
6969 return {
7070 sbot_blobs_add: rec.sink(function (cb) {
7171 return pull(
72- Hash(cb),
72+ Hash(function (err, id) {
73+ if(err) return cb(err)
74+ //completely UGLY hack to tell when the blob has been sucessfully written...
75+ var start = Date.now(), n = 5
76+ ;(function next () {
77+ setTimeout(function () {
78+ sbot.blobs.has(id, function (err, has) {
79+ if(has) return cb(null, id)
80+ if(n--) next()
81+ else cb(new Error('write failed'))
82+ })
83+ }, Date.now() - start)
84+ })()
85+ }),
7386 sbot.blobs.add()
7487 )
7588 }),
7689 sbot_links: rec.source(function (query) {
@@ -108,4 +121,6 @@
108121 })
109122 }
110123 }
111124
125+
126+

Built with git-ssb-web