From 25312aef021f4a29ee19953a3a73e940179e2cf5 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 20 Sep 2016 09:56:34 -0300 Subject: [bug] delay send of generated key if token is not available (#8460) --- src/leap/bitmask/core/mail_services.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index 8935bdd0..4b1d2113 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -29,6 +29,8 @@ from collections import namedtuple from twisted.application import service from twisted.internet import defer +from twisted.internet import reactor +from twisted.internet import task from twisted.python import log from twisted.python.procutils import which @@ -249,10 +251,15 @@ class KeymanagerContainer(Container): # but this hasn't been successfully uploaded. How do we know that? # XXX Should this be a method of bonafide instead? # ----------------------------------------------------------------- + log.msg("Key generated succesfully for %s" % userid) + if not self.get_instance(userid).token: + log.msg("Token not available yet, " + "wait before attempting to send key...") + return task.deferLater(reactor, 5, send_key, None) + log.msg("Sending key to server.") d = keymanager.send_key() d.addCallbacks( - lambda _: log.msg( - "Key generated successfully for %s" % userid), + lambda _: log.msg("Key sent to server."), log_key_error("sending")) return d -- cgit v1.2.3