aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Ball <chris@printf.net>2015-05-27 10:43:03 -0400
committerChris Ball <chris@printf.net>2015-05-27 10:43:03 -0400
commitd38b02a017e8d23cc6db6227bb6606c63a677227 (patch)
tree637ca47d9d4f04217127bbd95746e01d06a04ed7
parent2b5710fe762a56b9908672ebc887ad08660a3374 (diff)
gitswarmd: Update for new user profile format
-rwxr-xr-xgitswarmd39
1 files changed, 21 insertions, 18 deletions
diff --git a/gitswarmd b/gitswarmd
index baab74f..e7a6046 100755
--- a/gitswarmd
+++ b/gitswarmd
@@ -23,7 +23,9 @@ var dht = new DHT({
})
dht.listen(6882)
-var announcedRefs = {}
+var announcedRefs = {
+ master: {}
+}
var userProfile = {
name: '',
email: '',
@@ -94,22 +96,23 @@ dht.on('ready', function () {
sha = sha.substring(4)
var ref = arr[1].toString()
if (ref.search(/^refs\/heads\//) !== -1 || ref.search(/^refs\/remotes\//) !== -1) {
- console.log('Announcing ' + sha + ' for ref ' + ref + ' on repo ' + repo)
- announcedRefs.master = {}
- announcedRefs.master[sha] = repo
- var reponame = repo.replace(/\/.git\/$/, '')
- userProfile.repositories[reponame] = {}
- userProfile.repositories[reponame].master = sha
- // Callback counting for repos
- count--
- if (count <= 0) {
- publish_mutable_key()
- }
- dht.announce(sha, 30000, function (err) {
- if (err !== null) {
- console.log('Announced ' + sha)
+ if (!announcedRefs.master[sha]) {
+ console.log('Announcing ' + sha + ' for ref ' + ref + ' on repo ' + repo)
+ announcedRefs.master[sha] = repo
+ var reponame = repo.replace(/\/.git\/$/, '')
+ userProfile.repositories[reponame] = {}
+ userProfile.repositories[reponame].master = sha
+ // Callback counting for repos
+ count--
+ if (count <= 0) {
+ publish_mutable_key()
}
- })
+ dht.announce(sha, 30000, function (err) {
+ if (err !== null) {
+ console.log('Announced ' + sha)
+ }
+ })
+ }
}
}
})
@@ -161,10 +164,10 @@ dht.on('ready', function () {
console.error('calling git pack-objects')
var filename = sha + '.pack'
var stream = fs.createWriteStream(filename)
- if (!announcedRefs[sha]) {
+ if (!announcedRefs.master[sha]) {
console.error('Asked for an unknown sha!')
}
- var directory = announcedRefs[sha]
+ var directory = announcedRefs.master[sha]
var pack = spawn('git', ['pack-objects', '--revs', '--thin', '--stdout', '--delta-base-offset'], {cwd: directory})
pack.on('close', function (code) {
if (code !== 0) {