git ssb

0+

cryptop / multiblob



forked from Dominic / multiblob

Commit 71f686622a5db9cf61e832d8abb372970f5752d4

implement ls stream in terms of pull-live

Dominic Tarr committed on 5/20/2016, 7:12:55 AM
Parent: 6027d0f68dd4a7385c9d5a573f73af734303dafd

Files changed

index.jschanged
index.jsView
@@ -9,9 +9,9 @@
99 var glob = require('pull-glob')
1010 var paramap = require('pull-paramap')
1111 var cat = require('pull-cat')
1212 var Notify = require('pull-notify')
13-
13+var Live = require('pull-live')
1414 var Write = require('pull-write-file')
1515 var Read = require('pull-file')
1616
1717 var u = require('./util')
@@ -226,43 +226,32 @@
226226 })
227227
228228 return deferred
229229 },
230- ls: function (opts) {
231- opts = opts || {}
232- var isOld = opts.old !== false
233- var isLive = opts.live === true || opts.old === false
234230
235- if(!isLive && !isOld)
236- throw new Error('ls with neither old or new is empty')
237-
231+ ls: Live(function old (opts) {
238232 var long = (opts.size || opts.long || opts.meta)
239- var old = pull(
233+ return pull(
240234 glob(path.join(dir, '*', '*', '*')),
241235 long ? paramap(function (filename, cb) {
242236 stat(filename, function (err, stat) {
243237 cb(err, toMeta(toHash(filename), stat))
244238 })
245239 }, 32) : pull.map(toHash)
246240 )
247-
248- if(!isLive) return old
249-
250- var live = long
241+ }, function live (opts) {
242+ var long = (opts.size || opts.long || opts.meta)
243+ return long
251244 ? newBlob.listen()
252245 : pull(newBlob.listen(), pull.map(function (e) { return e.id }))
246+ }),
253247
254- if(!isOld) return live
255-
256- //old & live
257- return cat([old, pull.once({sync: true}), live])
258- },
259248 rm: function (hash, cb) {
260249 fs.unlink(toPath(dir, hash), cb)
261250 },
251+
262252 resolve: function (hash) {
263253 return toPath(dir, hash)
264254 }
265255 }
266256 }
267257
268-

Built with git-ssb-web