diff sat/memory/disco.py @ 2587:e70023e84974

core (disco): fixed disco capabilities (empty disco was used)
author Goffi <goffi@goffi.org>
date Tue, 22 May 2018 09:59:58 +0200
parents 26edcf3a30eb
children 56f94936df1e
line wrap: on
line diff
--- a/sat/memory/disco.py	Fri May 11 20:06:06 2018 +0200
+++ b/sat/memory/disco.py	Tue May 22 09:59:58 2018 +0200
@@ -84,7 +84,13 @@
         def fillHashes(hashes):
             for hash_, xml in hashes.iteritems():
                 element = xml_tools.ElementParser()(xml)
-                self.hashes[hash_] = disco.DiscoInfo.fromElement(element)
+                disco_info = disco.DiscoInfo.fromElement(element)
+                if not disco_info.features and not disco_info.identities:
+                    log.warning(_(u"no feature/identity found in disco element (hash: {cap_hash}), ignoring: {xml}").format(
+                        cap_hash=hash_, xml=xml))
+                else:
+                    self.hashes[hash_] = disco_info
+
             log.info(u"Disco hashes loaded")
         d = self.persistent.load()
         d.addCallback(fillHashes)
@@ -158,10 +164,10 @@
         if jid_ is None:
             jid_ = jid.JID(client.jid.host)
         try:
-            cap_hash = self.host.memory.getEntityData(jid_, [C.ENTITY_CAP_HASH], client.profile)[C.ENTITY_CAP_HASH]
             if not use_cache:
                 # we ignore cache, so we pretend we haven't found it
                 raise KeyError
+            cap_hash = self.host.memory.getEntityData(jid_, [C.ENTITY_CAP_HASH], client.profile)[C.ENTITY_CAP_HASH]
         except (KeyError, exceptions.UnknownEntityError):
             # capability hash is not available, we'll compute one
             def infosCb(disco_infos):