summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2017-07-20 09:19:19 +0200
committerJürg Billeter <j@bitron.ch>2017-07-20 09:25:17 +0200
commit46d62c2169759ea8af3fce4bd9cdd75b168eb123 (patch)
tree9eb45cf996792a02683be4d3972669ce1f37b74a
parent7f6ed26674bd567dd1ce63a3fe844eb6646d9c39 (diff)
downloadbuildstream-push-protocol.tar.gz
_artifactcache/pushreceive.py: Do not list all refspush-protocol
The full ref list can easily exceed the maximum message size. Limit list to refs being pushed. Fixes #47
-rw-r--r--buildstream/_artifactcache/pushreceive.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/buildstream/_artifactcache/pushreceive.py b/buildstream/_artifactcache/pushreceive.py
index 27e80cf2b..0706b5e41 100644
--- a/buildstream/_artifactcache/pushreceive.py
+++ b/buildstream/_artifactcache/pushreceive.py
@@ -135,13 +135,21 @@ class PushMessageWriter(object):
self.file.write(msg)
self.file.flush()
- def send_info(self, repo):
+ def send_info(self, repo, refs):
cmdtype = PushCommandType.info
mode = repo.get_mode()
- _, refs = repo.list_refs(None, None)
+
+ ref_map = {}
+ for ref in refs:
+ _, checksum = repo.resolve_rev(ref, True)
+ if checksum:
+ _, has_object = repo.has_object(OSTree.ObjectType.COMMIT, ref, None)
+ if has_object:
+ ref_map[ref] = checksum
+
args = {
'mode': GLib.Variant('i', mode),
- 'refs': GLib.Variant('a{ss}', refs)
+ 'refs': GLib.Variant('a{ss}', ref_map)
}
command = PushCommand(cmdtype, args)
self.write(command)
@@ -416,6 +424,9 @@ class OSTreePusher(object):
remote_refs = {}
update_refs = {}
+ # Send info immediately
+ self.writer.send_info(self.repo, list(self.refs.keys()))
+
# Receive remote info
logging.info('Receiving repository information')
args = self.reader.receive_info()
@@ -504,8 +515,12 @@ class OSTreeReceiver(object):
raise
def do_run(self):
- # Send info immediately
- self.writer.send_info(self.repo)
+ # Receive remote info
+ args = self.reader.receive_info()
+ remote_refs = args['refs']
+
+ # Send info back
+ self.writer.send_info(self.repo, list(remote_refs.keys()))
# Wait for update or done command
cmdtype, args = self.reader.receive([PushCommandType.update,