Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssb-git-repo

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssb-git-repo - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

test/repo.js

64

lib/repo.js

@@ -50,3 +50,3 @@ var pull = require('pull-stream')

length: obj.length,
key: obj.key
link: obj.link
}

@@ -109,5 +109,2 @@ }

var obj = c.objects[sha1]
this._objects[sha1] = obj
// complete waiting lookups
this._addObject(sha1, obj)

@@ -138,7 +135,8 @@ }

// read index of git SHA1 -> object info from a blob
// read index of git SHA1 -> object info from a blob.
// DEPRECATED
Repo.prototype._readExternalObjects = function (blobId) {
if (!ref.isBlobId(blobId)) return
if (blobId in this._externalBlobsRead)
return console.error('skip ext', blobId)
return
this._externalBlobsRead[blobId] = true

@@ -328,3 +326,5 @@ var cb = this._hashLookupsMulticb()

if (!obj) return cb(new Error('Object not present with hash ' + hash))
this._getBlob(obj.key, function (err, read) {
var blobId = obj.link || obj.key
if (!blobId) return cb(new Error('Object is missing blob key'))
this._getBlob(blobId, function (err, read) {
if (err) return cb(err)

@@ -344,3 +344,2 @@ cb(null, {

var allObjects = this._objects
var maxObjects = 400
var objects = []

@@ -392,3 +391,3 @@ var ended

length: object.length,
key: blobKey,
link: blobKey,
sha1: sha1 // this gets removed by objectsArrayToMap before publish

@@ -409,46 +408,9 @@ })

// max msg size is 8192 bytes.
// when the objects list is too big to fit,
// put it in a blob and link to that.
if (objects.length > maxObjects) {
tryPublish()
} else {
msg.objects = objectsArrayToMap(objects)
next()
}
})
function tryPublish() {
// console.error('trying', maxObjects, new Date())
// move objects from the message into the external blob
// until the message is small enough to publish.
// TODO: put high-priority objects in the message first,
// e.g. branch heads and root trees and readmes
msg.objects = objectsArrayToMap(objects.slice(0, maxObjects))
var objsExt = objectsArrayToMap(objects.slice(maxObjects))
var hashDone = multicb({pluck: 1, spread: true})
pull(
pull.once(JSON.stringify(objsExt)),
createSSBBlobHash(hashDone()),
sbot.blobs.add(hashDone())
)
hashDone(function (err, blobKey) {
if (err) return cb(err)
msg.objects_ext = blobKey
next()
})
}
function next() {
msg.objects = objectsArrayToMap(objects)
sbot.publish(msg, function (err, msg) {
if (err) {
if (/must not be large/.test(err.message)) {
if (maxObjects <= 1) {
cb(new Error('Message is too big to send'))
} else {
maxObjects >>= 1
tryPublish()
}
// max msg size is 8192 bytes.
// TODO: do something better here
cb(new Error('Update is too big to send! Try pushing fewer commits.'))
} else {

@@ -462,3 +424,3 @@ cb(err)

})
}
})
}
{
"name": "ssb-git-repo",
"version": "1.0.0",
"version": "1.1.0",
"description": "git repos in secure-scuttlebutt",
"main": "index.js",
"scripts": {
"test": "node test"
"test": "tape test/*.js"
},

@@ -9,0 +9,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc