git ssb

3+

cel / ssb-npm-registry



Commit e335ffa5bc6c1a847bbb992f930f62c780d3b244

Hard-code workaround for large blob

cel committed on 11/29/2019, 9:52:48 PM
Parent: 5eeba2c58721e0dda8b9b829f4b3feb22e7a9a26

Files changed

index.jschanged
index.jsView
@@ -384,8 +384,16 @@
384384 var blobs = sbot.blobs
385385 blobs.size(id, function (err, size) {
386386 if (err && err.code !== 'ENOENT') return cb(err)
387387 if (typeof size === 'number') return cb(null, blobs.get(id), size)
388 + if (id === '&pSqSdJEJMxbUiDWMNRd1RP47m5M1MD4IeasDYY4jrwg=.sha256') {
389 + // sodium-native v2.4.6 (12M)
390 + return getLargeBlob(sbot, [
391 + '&d+J8NSPD1QRMLtLkyoRgq3ShPpqsgzCGUOTh+U6wPH0=.sha256',
392 + '&u4Ih2XRhQmWw5FElWjK1weSuDBn8hfSVn96lFbJHts0=.sha256',
393 + '&kW4d1Dz1sm0Y4az+qXPkcew3+LD6Om5+06STSihRWMk=.sha256'
394 + ], cb)
395 + }
388396 var timeout = wantWarnTime > 0 && setTimeout(function () {
389397 console.error('Blob taking a long time to fetch:', id)
390398 }, wantWarnTime)
391399 blobs.want(id, function (err, got) {
@@ -399,8 +407,25 @@
399407 })
400408 })
401409 }
402410
411 +function getLargeBlob(sbot, ids, cb) {
412 + var done = multicb({pluck: 1})
413 + var totalSize = 0
414 + ids.forEach(function (id) {
415 + var cb = done()
416 + getBlob(sbot, id, function (err, source, size) {
417 + if (err) return cb(err)
418 + totalSize += size
419 + cb(null, source)
420 + })
421 + })
422 + done(function (err, sources) {
423 + if (err) return cb(err)
424 + cb(null, cat(sources), totalSize)
425 + })
426 +}
427 +
403428 function getMentions(links2, name) {
404429 return links2.read({
405430 query: [
406431 {$filter: {rel: ['mentions', name, {$gt: true}]}},

Built with git-ssb-web