diff options
author | Jürg Billeter <j@bitron.ch> | 2017-07-20 09:19:19 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-07-20 09:59:15 +0000 |
commit | 977210795c9ec67309eae3b78e2100c6b2281823 (patch) | |
tree | 57fbdf02ffc57cf21bcf8a29f32ca90880ebc179 | |
parent | 4db12c367c4818321517360fdcafc273fd318a2f (diff) | |
download | buildstream-977210795c9ec67309eae3b78e2100c6b2281823.tar.gz |
_artifactcache/pushreceive.py: Do not list all refs
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.py | 25 |
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, |