git ssb

2+

Dominic / flumedb



Commit 8722445354150e8ebe0adaa754aa875e0cc8edd9

expose .closed property, so can check whether database is closed

Dominic Tarr committed on 6/29/2017, 3:01:17 AM
Parent: 9a1552566c99ce0139006a43936bf9fd109afa1c

Files changed

index.jschanged
index.jsView
@@ -18,12 +18,10 @@
1818
1919 module.exports = function (log, isReady) {
2020 var views = []
2121 var meta = {}
22- var closed = false
2322
2423 log.get = count(log.get, 'get')
25-// log.stream = count(log.stream, 'stream')
2624
2725 function count (fn, name) {
2826 meta[name] = meta[name] || 0
2927 return function (a, b) {
@@ -34,8 +32,9 @@
3432
3533 var ready = Obv()
3634 ready.set(isReady !== undefined ? isReady : true)
3735 var flume = {
36 + closed: false,
3837 dir: log.filename ? path.dirname(log.filename) : null,
3938 //stream from the log
4039 since: log.since,
4140 ready: ready,
@@ -66,9 +65,9 @@
6665 sv.since.once(function (upto) {
6766 pull(
6867 log.stream({gt: upto, live: true, seqs: true, values: true}),
6968 sv.createSink(function (err) {
70- if(err && !closed) console.error(err)
69 + if(err && !flume.closed) console.error(err)
7170 })
7271 )
7372 })
7473
@@ -96,10 +95,10 @@
9695 //then restream each streamview, and callback when it's uptodate with the main log.
9796 })
9897 },
9998 close: function (cb) {
100- if(closed) throw new Error('already closed')
101- closed = true
99 + if(flume.closed) throw new Error('already closed')
100 + flume.closed = true
102101 cont.para(map(views, function (sv, k) {
103102 return function (cb) {
104103 if(sv.close) sv.close(cb)
105104 else cb()
@@ -117,4 +116,6 @@
117116
118117
119118
120119
120 +
121 +

Built with git-ssb-web